This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11393] Initializer of static const float class member is not legal in c++98


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

--- Comment #20 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-10-25 23:44:01 UTC ---
BTW, clang accepts "b" as a GNU extension, and it does not care at all about
"c" (except for the -Wconversion warning that is enabled by default).

manuel@gcc10:~$ ~/bin/clang++ -std=c++98 test.cc
test.cc:3:21: warning: in-class initializer for static data member of type
'const float' is a GNU extension [-Wgnu]
 static const float b = 3;
                    ^   ~
test.cc:4:23: warning: implicit conversion from 'double' to 'int' changes value
from 3.1415926 to 3 [-Wliteral-conversion]
 static const int c = 3.1415926;
                  ~   ^~~~~~~~~
2 warnings generated.
manuel@gcc10:~$ ~/bin/clang++ -std=c++11 test.cc
test.cc:3:21: warning: in-class initializer for static data member of type
'const float' is a GNU extension [-Wgnu]
 static const float b = 3;
                    ^   ~
test.cc:3:21: note: use 'constexpr' specifier to silence this warning
 static const float b = 3;
                    ^
 constexpr 
test.cc:4:23: warning: implicit conversion from 'double' to 'int' changes value
from 3.1415926 to 3 [-Wliteral-conversion]
 static const int c = 3.1415926;
                  ~   ^~~~~~~~~
2 warnings generated.

To be honest, I like infinitely more the behaviour of clang.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]