public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/7243: cannot declare an array at file level with constant expression for size
@ 2002-07-09 6:56 jonathan.ashley
0 siblings, 0 replies; 2+ messages in thread
From: jonathan.ashley @ 2002-07-09 6:56 UTC (permalink / raw)
To: gcc-gnats
>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];
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c/7243: cannot declare an array at file level with constant expression for size
@ 2002-07-09 8:28 nathan
0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-07-09 8:28 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jonathan.ashley, nobody
Synopsis: cannot declare an array at file level with constant expression for size
State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Tue Jul 9 08:28:53 2002
State-Changed-Why:
not a bug. The array dimension must be an integral constant
expression.
const int x = 1;
int y[x]; /* not such an expression */
refer to A7.19.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7243
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-09 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-09 6:56 c/7243: cannot declare an array at file level with constant expression for size jonathan.ashley
2002-07-09 8:28 nathan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).