static array with constant size

Andrew Pinski pinskia@gmail.com
Wed Mar 5 07:58:00 GMT 2008


On 3/4/08, Elazar Leibovich <elazarl@gmail.com> wrote:
> I'm trying to compile the following piece of code:
>  static const int ln = 10;
>  static int ar[ln];
>  I'm getting:
>  storage size of 'ar' isn't constant
>  size of variable 'ar' is too large
>   Is the code legal? Can you provide me with references to its legality
>  or a discussion about it? it seems to be compilable with MS cl.exe.

First, this is the wrong list, gcc-help@gcc.gnu.org is a better list.
Second this is valid C++98/C++03 but invalid C90/C99.  In C90/C99,
variables are not constant integral expressions while in C++98/C++03,
initialized static constant variables are.

-- Pinski



More information about the Gcc mailing list