Variable array bound

Ryan Mansfield
Wed Mar 8 15:29:00 GMT 2006

> Should this compile? My version of Stroustrup's 'The C++ Programming
> Language (c) 2000' states in section 5.2: "The number of elements of the
> array, the array bound, must be a constant expression".
> Is this by any chance a gcc extension?

Variable-length automatic arrays are allowed in ISO C99, and as an extension
GCC accepts them in C89 mode and in C++. If you don't want this to compile,
-pedantic will reject code with extensions.

Ryan Mansfield


More information about the Gcc-help mailing list