c/7243: cannot declare an array at file level with constant expression for size
jonathan.ashley@praxis-cs.co.uk
jonathan.ashley@praxis-cs.co.uk
Tue Jul 9 06:56:00 GMT 2002
>Number: 7243
>Category: c
>Synopsis: cannot declare an array at file level with constant expression for size
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Jul 09 06:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Jon Ashley
>Release: 3.1.1 20020706 (prerelease)
>Organization:
>Environment:
Cygwin on Windows 2000. (Also reproduced on version 2.8.1 on Solaris.)
>Description:
If an array is declared at file level with a size given by a named constant (declared as 'const int x = 5' for example), the compiler incorrectly rejects it with the message "variable-size type declared outside of any function". This conflicts with A8.6.2 from K&R2.
>How-To-Repeat:
const int x = 1;
int y[x];
gcc -c demo.c
>Fix:
Don't do this.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="demo.c"
Content-Disposition: inline; filename="demo.c"
const int x = 1;
int y[x];
More information about the Gcc-prs
mailing list