Is this correct ? This is compiled with g++ (3.4) sucessfully.
int main() { int x = 12; char pz[x]; }
G++ supports a C99 feature that allows dynamically sized arrays. It is not standard C++. G++ has the -ansi
option that turns off some features that aren't in C++, but this isn't one of them. To make G++ reject that code, use the -pedantic
option:
$ g++ -pedantic junk.cpp junk.cpp: In function ‘int main()’: junk.cpp:4: error: ISO C++ forbids variable-size array ‘pz’