This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

c/7243: cannot declare an array at file level with constant expression for size


>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];


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