Re: [C++0x] code that used to be accepted isn't accepted anymore (related to constexpr changes?)

Zdeněk Sojka
Sun Nov 7 00:47:00 GMT 2010

Thank you for answers!

> On Sat, Nov 6, 2010 at 12:30 PM, Benoit Jacob <> wrote:
> > I'm not a GCC dev; but I believe that it's normal that this code gets
> > rejected. There's nothing in the c++98 or c++0x specs that guarantees
> > that constant global variables are actually constant --- as you could
> > in theory take pointers to them, const_cast, and dereference. It just
> > so happens that (at least here on gnu+linux) gcc puts such constant
> > global variables in a read-only segment, so that doing that is an
> > access violation. In other words, it was pretty unsafe that GCC
> > accepted this code and I'm glad to head it is now rejecting it :)
> That makes no sense to me.

Ok, I will change "static const" back to plain old "#define"s, as that seems to work.

> The compiler is right: the value of `x' cannot fit in an int, therefore the
> declaration is ill-formed.  This has nothing to do with constexpr.

(-1) isn't representible in unsigned as well, but I suppose I should read the c++0x "standard" then, thanks :)


More information about the Gcc-help mailing list