[Bug c++/31904] fail to link to static const double

fang at csl dot cornell dot edu gcc-bugzilla@gcc.gnu.org
Sat May 12 16:53:00 GMT 2007



------- Comment #7 from fang at csl dot cornell dot edu  2007-05-12 17:53 -------
Subject: Re:  fail to link to static const double

> ------- Comment #6 from dennis0yang at gmail dot com  2007-05-12 17:19 -------
> Subject: Re:  fail to link to static const double
>
> I understand perfectly well everything you said. But I think you miss
> the point of this bug report.
> This is not about the c++ standard in terms of what should and should
> not be done. This is about get rid of the "luck" component in gcc. If
> gcc decides not to support in-class definition for static const double,
> then flag the statement as an error. I really don't see why the compile

You can reject non-integer in-class static const definitions with:
CXXFLAGS += -ansi -pedantic-errors
(also rejects many other non-standardisms, if you're prepared to do so!)

> doesn't substitute the value everywhere it see the reference (as you
> mentioned), because it is a static const!

The compiler is really not required to do even the simplest of
optimizations.  -O0 really means NO optimizations, even the no-brainers
such as this one.

FWIW, as a user, I build/test with different optimization levels to catch
these sort of errors (in case I forget a const definition).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31904



More information about the Gcc-bugs mailing list