possible bug in g++

Jonathan Wakely jwakely.gcc@gmail.com
Thu Feb 16 10:00:00 GMT 2012


On 16 February 2012 09:53, Mattia Jona-Lasinio wrote:
> Hmmm, I see the problem. I just find very confusing that the
> compilation of wrong code be compiler dependent or version dependent.
> Wouldn't it be better to mark it as invalid code and to signal it?

That's not generally possible. The compiler cannot tell that you're
going to get a linker error later. When compiling a file it's possible
that the missing definition will be present in some other file and
provided at link time.  That's why the standard says "no diagnostic
required".

> Maybe one could allow the compiler to accept the code with a
> -fpermissive flag. Anyway, thanks a lot!

No, it's better for people to just learn the simple rule that a static
const member that is initialized in-class also needs an out-of-class
definition.



More information about the Gcc-help mailing list