This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: V3 PATCH: Static data members
>>>>> "Gabriel" == Gabriel Dos Reis <gdr@codesourcery.com> writes:
Gabriel> Mark Mitchell <mark@codesourcery.com> writes:
Gabriel> | G++ doesn't handle static data members well (they are
Gabriel> not implicitly | instantiated) on AIX, and it may not do
Gabriel> so in the near future. It | handles *const* static data
Gabriel> members better, because it often doesn't | actually
Gabriel> allocate storage for the constants.
Gabriel> Is that a conforming behaviour? static data members have
Gabriel> external linkage and I would expect the compiler to
Gabriel> allocate storage for such beasts.
The compiler is free not to allocate storage for them if they are
defined in-class. (Since then by the ODR they must be present in all
translations where they are needed.) For out-of-class definitions,
I'm not sure. You could be right that the compiler is not strictly
conforming -- but the bottom line is that *V3* is still conforming,
and the compiler has an easier time. :-)
Gabriel> You've hit a reason why I recommand using enums where
Gabriel> possible in lieu of static integral data members. See a
Gabriel> recent patch of mine about _Count_ones<>.
The copmiler should treat in-class initialized static const data
members just like enums, and code written that way is cleaner. If the
compiler doesn't treat those two things identically, that is a
quality-of-implementation issue. I would recommend that in V3 we do
what we think makes the cleanest code; if the compiler generates
inferior code file a bug against the compiler.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com