This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: static const class member is undefined
Perhaps I wasn't specific enough: I am talking about static const class
member variables of integral types. ISO C++ allows these variables to be
initialized inside the class definition. Either way, it would be a bug
since only very specific code would cause this error: "return n != 0 ?
Foo::c : Foo::d;". Other use of the variables, such as "return Foo::c;",
is okay. Gcc generates a literal for the latter but a variable reference
for the former.
>> G++ creates undefined symbols for static const class member variables
>> for the test code in the attached file.
>
> It's ISO C++: class static data members must have a definition outside
> the class definition, even if they are const.
>
> --
> Eric Botcazou
>