This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Constant expression for array subscript operator
- To: Craig Rodrigues <rodrigc at mediaone dot net>
- Subject: Re: Constant expression for array subscript operator
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- Date: Fri, 20 Jul 2001 21:36:42 -0700
- Cc: gcc at gcc dot gnu dot org
> Should gcc emit an error message on the following piece of
> code? gcc 3.0.1 seems to compile it without complaining,
> and only issues a warning if I add the -pedantic flag.
>
> #include <cstdio>
> void foo(int a)
> {
> char b[a];
> std::printf("Hello %c\n", b[9]);
> }
This is a non-standard GNU extension (which is useful, of course).
See section 5.14 in http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_5.html
(and the rest of the page for more extensions).
-tim