http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #9 from Jonathan Wakely 2010-09-30
08:10:39 UTC ---
(In reply to comment #8)
>
> But -a (or 0.0-a) is not a constant expression, so having an in-class
> initializer seems suspicious, couldn't we warn at least?
Eh? It could be used
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #8 from Manuel López-Ibáñez 2010-09-29
23:22:59 UTC ---
(In reply to comment #7)
> (In reply to comment #6)
> >
> > What is the point of allowing to initialize it then?
>
> Static const members declared with initializers can be used
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #7 from Jonathan Wakely 2010-09-29
22:59:39 UTC ---
(In reply to comment #6)
>
> What is the point of allowing to initialize it then?
Static const members declared with initializers can be used in constant
expressions, see 9.4.2p4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
Manuel López-Ibáñez changed:
What|Removed |Added
CC||manu at gcc dot gnu.org
--- Comment
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
Paolo Carlini changed:
What|Removed |Added
CC||paolo.carlini at oracle dot
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #4 from Sander Land 2010-09-29
13:05:45 UTC ---
(In reply to comment #3)
> You didn't. A definition would be
>
> const double x::a;
>
> at file-scope. Your "definition" is a declaration.
Fair enough, I thought it was both. Still
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #3 from Richard Guenther 2010-09-29
12:53:52 UTC ---
You didn't. A definition would be
const double x::a;
at file-scope. Your "definition" is a declaration.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #2 from Sander Land 2010-09-29
12:49:23 UTC ---
I did define the constant, though now see the attachment apparently failed?
Full text below:
struct x {
static const double a = 3.14;
double f() {
double b = -a;// undefined ref
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
Richard Guenther changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|