[wwwdocs] Add a note about in-class initialization of static data member

Marek Polacek polacek@redhat.com
Thu Feb 11 18:51:00 GMT 2016


On Thu, Feb 11, 2016 at 11:45:37AM -0700, Martin Sebor wrote:
> >>   struct X {
> >>     const static double i = 3.14;
> >>   };
> >>
> >>   error: floating-point literal cannot appear in a constant-expression
> >>     const static double i = 3.14;
> >>                            ^~~~
> >
> >Hm, indeed; I hadn't notice that.  Dunno if is a bug (clang++ accepts this
> >with a warning).  I've added ", provided the initializer is an integer",
> >that should be enough.
> 
> I don't think documenting this as a blanket restriction is right.
> The code is silently accepted without -Wpedantic and few people
> use the option so the added text would be misleading as is.  But
> my feeling is that this is just a bug, in which case I wouldn't
> expect to see it documented in any case.

Ok, I'll drop that note then.
 
> The flexible array addition looks great to me. Thank you!

Great.  I'll commit the patch.

	Marek



More information about the Gcc-patches mailing list