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

--- Comment #19 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-25 
23:29:59 UTC ---
I think there are several issues conflated in this report. Perhaps the
following example is clearer:

class B { 
 static const int a = 1;     
 static const float b = 3;
 static const int c = 3.1415926;
};

Both -std=c++11 -pedantic and just -std=c++11 give:
error: ‘constexpr’ needed for in-class initialization of static data member
‘const float B::b’ of non-integral type [-fpermissive]
  static const float b = 3;
                         ^

-std=c++98 -pedantic gives
warning: ISO C++ forbids initialization of member constant ‘B::b’ of
non-integral type ‘const float’ [-Wpedantic]
  static const float b = 3;
                         ^
error: floating-point literal cannot appear in a constant-expression
  static const int c = 3.1415926;
                       ^

and -std=c++98 gives nothing.

Now, the first issue that Joseph discusses is that -std=, as currently
implemented, is not supposed to give all diagnostics required by the standard,
that is what -pedantic is for. Others disagree. Well, in this case, this issue
is moot, since the initialization of "b" is anyway a deprecated feature (and a
permerror in c++11), I would say: just make it a permerror also in c++98. Some
users may complain, but I think will make happy both Richard and Joseph.

The second bug I see here is that -pedantic creates a hard error for "c". This
is wrong. It is either a hard error all the time (with or without -pedantic) or
a permerror all the time, or it is a -pedantic warning that can be transformed
into an error by -pedantic-errors.

But there is probably even a third bug: are floating point literals accepted in
constant-expressions in c++11? If so, then the usual is to accept it in c++98
as an extension but warn with -pedantic (why reject something that is
implemented?). Otherwise, it should be rejected also in c++11.

Reply via email to