Fw: new requirement of "constexpr" for static const float data members is too restrictive
Gabriel Dos Reis
gdr@integrable-solutions.net
Tue Nov 30 00:20:00 GMT 2010
On Mon, Nov 29, 2010 at 3:24 PM, Roman Kononov <roman@xtremedata.com> wrote:
> $ cat test.cc
> struct X { static float const v=1; };
>
> $ g++ -c -std=gnu++0x test.cc
> test.cc:1:33: error: 'constexpr' needed for in-class initialization of
> static data member 'v' of non-integral type
>
> This will break a great deal of existing c++ code preventing easy
> transition to c++0x. Maybe, the constexpr requirement should be relaxed
> in gnu++0x mode.
>
> Please see the trivial patch.
I believe you may be confused.
Your program does not use `constexpr' at all, so I think your $SUBJECT and
prognosis is not right. The above code is invalid C++03 code. It stays
invalid in C++0x. However, if you do want to write something like that
in C++0x, you do have to use `constexpr' -- that is what the diagnostic
message is saying.
Summary: this is a non-issue.
-- Gaby
More information about the Gcc
mailing list