static const double pi = 3.1415;
Mike Stump
mstump@apple.com
Wed Feb 19 18:18:00 GMT 2003
On Wednesday, February 19, 2003, at 09:25 AM, Nathan Sidwell wrote:
> Mike Stump wrote:
>
>> Seems like I am just too radical for ya'll:
> > static const double d = 3.1415;
> >
> > int main() {
> > foo(d);
> > }
> > static const double d = 3.1415;
>
>> The above C program seemed to work in C++ as well. Either, that is a
>> bug in C and C++, or somewhere, it is defined well enough to work.
>
> We were talking about static *member* constants, not plain static
> constants. The latter are well formed (they do not have to be
> initialized
> by a constant expression).
I still feel like I am on Mars:
LC0:
.long 1074340298
.long -1065151889
_main:
LFB1:
mflr r3
stw r31,-4(r1)
LCFI0:
bcl 20,31,L1$pb
L1$pb:
stw r3,8(r1)
LCFI1:
mflr r31
stwu r1,-80(r1)
LCFI2:
addis r2,r31,ha16(LC0-L1$pb)
lfd f1,lo16(LC0-L1$pb)(r2)
bl L__Z3food$stub
Like I said, you may not know fine, but my compiler, and the language
standard, unless you can claim it is a bug in the compiler, they know.
Oh, and by the way if you are correct, that it can be something other
than a constant, why does the compiler give:
bash-2.05a$ gcc -O3 -S t.c
t.c:3: initializer element is not constant
in the case of C.
double bar();
static const double d = bar();
void foo(double);
int main() {
foo(d);
}
is this a bug in the compiler that needs fixing?
More information about the Gcc
mailing list