This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Variable array bound
> > 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.
Thanks for the feedback (and to Aseem for the link). It's not a problem
for me, I was just curious as to why it was working and whether anyone
knew about it. I guess it's not a great idea to use it in g++ (although
it is quite nifty) if you're also planning to compile your code with
other compilers.
Regards
Stuart