* initializer bug?
@ 1998-03-10 7:16 Neal Becker
1998-03-10 17:06 ` Richard Henderson
1998-03-10 17:06 ` Jim Wilson
0 siblings, 2 replies; 3+ messages in thread
From: Neal Becker @ 1998-03-10 7:16 UTC (permalink / raw)
To: egcs
Isn't this a bug?
------
Test.c:
static const int A = 2;
static const int B = A/2;
------
gcc -c Test.c
Test.c:2: initializer element is not constant
Sure looks constant to me.
This is egcs-1.0.1 i686 linux
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: initializer bug?
1998-03-10 7:16 initializer bug? Neal Becker
@ 1998-03-10 17:06 ` Richard Henderson
1998-03-10 17:06 ` Jim Wilson
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1998-03-10 17:06 UTC (permalink / raw)
To: Neal Becker; +Cc: egcs
On Tue, Mar 10, 1998 at 10:15:47AM -0500, Neal Becker wrote:
> Isn't this a bug?
>
> static const int A = 2;
> static const int B = A/2;
That is only valid in C++. In ISO C, a const int is not a
compile-time constant expression.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: initializer bug?
1998-03-10 7:16 initializer bug? Neal Becker
1998-03-10 17:06 ` Richard Henderson
@ 1998-03-10 17:06 ` Jim Wilson
1 sibling, 0 replies; 3+ messages in thread
From: Jim Wilson @ 1998-03-10 17:06 UTC (permalink / raw)
To: Neal Becker; +Cc: egcs
static const int A = 2;
static const int B = A/2;
gcc -c Test.c
Test.c:2: initializer element is not constant
Sure looks constant to me.
It isn't a constant; it is a variable. The value of the variable is constant,
but it is still a variable, and ISO C says that it must be treated as one
in this context.
It is valid C++ however, as C++ handles this case differently than C.
Jim
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-03-10 17:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-10 7:16 initializer bug? Neal Becker
1998-03-10 17:06 ` Richard Henderson
1998-03-10 17:06 ` Jim Wilson
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).