[Bug c++/14132] static template member definition fails
guillaume dot melquiond at ens-lyon dot fr
gcc-bugzilla@gcc.gnu.org
Thu Feb 12 20:03:00 GMT 2004
------- Additional Comments From guillaume dot melquiond at ens-lyon dot fr 2004-02-12 20:03 -------
Standard 9.4.2 (static data members) says: "A declaration of a static data
member in its class definition is not a definition [...] The definition for a
static data member shall appear in a namespace scope enclosing the member's
class definition." This part of the standard doesn't say it applies to static
data members of template classes; but since 14.5.1.3 (static data members of
class templates) doesn't explain what the situation is (at least not in my
version), I have supposed 9.4.2 should apply (since A<void> is a class, isn't it?).
9.4.2 says this code is valid:
struct B { int b; } // the "false" definition of B::b
int B::b; // the "real" definition, it is mandatory (9.4.2-5)
Now I'm trying to do exactly the same thing with the class A<void>. Since
A<void>::a "is not a definition" (and the linker is right to complain), I'm
trying to give the real definition of A<void>::a. GCC 3.3 and ICC 8.0 both
understand it is its real definition (as stated in 9.4.2); GCC 3.4 does not. And
adding "template<>" before the line does not create a "real" definition (since
the linker complains).
Hope I was clearer.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14132
More information about the Gcc-bugs
mailing list