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: Fri, 26 Oct 2012 00:23:46 +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 #24 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-10-26 00:23:46 UTC ---
Interestingly,
manuel@gcc10:~$ ~/bin/clang++ -std=c++98 pr11393.cc -pedantic-errors
pr11393.cc:3:21: error: in-class initializer for static data member of type
'const float' is a GNU extension [-Werror,-Wgnu]
static const float b = 3;
^ ~
pr11393.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;
~ ^~~~~~~~~
pr11393.cc:4:23: error: in-class initializer for static data member is not a
constant expression; folding it to a constant is a GNU extension
[-Werror,-Wpedantic]
static const int c = 3.1415926;
^~~~~~~~~
pr11393.cc:5:21: error: in-class initializer for static data member of type
'const float' is a GNU extension [-Werror,-Wgnu]
static const float d = 3.1415926;
^ ~~~~~~~~~
1 warning and 3 errors generated.
So, in g++ parlance, "b" and "d" is a pedwarn enabled by default, while "c" is
a pedwarn in c++98 mode enabled by -Wpedantic and nothing in c++11 mode.