Are there any scenarios where C4172 Visual C++ warning should not be considered an error?
c++, compiler-warnings, visual-c++
Solution
I'm not sure why anyone would ever want to do this:
int * stackTester()
{
int dummy;
return &dummy;
}
bool stackGoesUp()
{
int dummy;
return stackTester() > &dummy;
}
But generally speaking, you should treat the warning like an error.
Problem
There's C4172 Visual C++ warning for cases when a function returns an address of a local or temporary or a reference to a local variable. Something like this: ``` int& fun() { int var; return var; //C4172 } ``` Now looks like it is a good idea to use `#pragma warning` to make Visual C++ treat C4172 as error and break compilation. Are there any sane scenarios where C4172 is not actually an error?