I saw some published code with an error outside the SO range, which made me think. I expect the 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 this is not so.
The EDG compiler perfectly says:
"sourceFile.cpp", line 3: warning:
subscript out of range
x[2]=0;
^
Actually the EDG says a bit 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 is not my question.
I am considering this failure to prevent SERIOUS skipping errors in VC9 (especially since with an automatic variable !!!!). Can someone give me a good reason to change my mind?
source
share