This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Constant expression for array subscript operator




> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]