Gabriel Dos Reis <g...@integrable-solutions.net> writes: > On Mon, Nov 29, 2010 at 3:24 PM, Roman Kononov <ro...@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.
We could decide not to do anything about this, but I don't think it's a non-issue. With -std=gnu++98 g++ accepts this invalid code. That is, it is a g++ extension, and the code is properly rejected with -pedantic-errors. We could decide to carry the extension forward to -std=gnu++0x. Or we could decide to carry the extension forward to -std=gnu++0x when -fpermissive is used. Or we could decide to just drop the extension. The main problem with the last option is that it complicates the migration of existing gnu++98 programs to gnu++0x. It becomes necessary to add constexpr to use gnu++0x. Unfortunately, gnu++98 rejects constexpr. So there is no simple way to modify this program to be both valid gnu++98 and valid gnu++0x. That makes the transition more difficult. It seems to me that it would be better for our users to accept this code in gnu++0x mode with -fpermissive. Ian