This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11393] Initializer of static const float class member is not legal in c++98
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Oct 2012 23:44:01 +0000
- Subject: [Bug c++/11393] Initializer of static const float class member is not legal in c++98
- Auto-submitted: auto-generated
- References: <bug-11393-4@http.gcc.gnu.org/bugzilla/>
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.