I saw some posted code with an out of range error on SO that made me wonder. I would expect a compiler to generate a warning (at the highest level at least) for this code
#pragma warning(push,4)
int main(){
int x[2];
x[2]=0;
return 0;
}
#pragma warning(pop)
but it does not.
The EDG compiler nicely says:
"sourceFile.cpp", line 3: warning:
subscript out of range
x[2]=0;
^
Actually EDG says bit more more(all of which are expected)
"sourceFile.cpp", line 1: warning:
unrecognized #pragma
#pragma warning(push,4)
^
"sourceFile.cpp", line 4: warning:
subscript out of range
x[2]=0;
^
"sourceFile.cpp", line 3: warning:
variable "x" was set but never used
int x[2];
^
"sourceFile.cpp", line 7: warning:
unrecognized #pragma
#pragma warning(pop)
but that's not my question.
I consider this failure to warn a SERIOUS error of omission in VC9,(even more so since an auto variable!!!!). Can anyone give me a serious reason to change my mind?