This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/14132] static template member definition fails


------- Additional Comments From gdr at integrable-solutions dot net  2004-02-13 00:59 -------
Subject: Re:  static template member definition fails

"guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla@gcc.gnu.org> writes:

| 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, the standard certainly tells you the syntax of out-of-class
member definition of a template; it must start with the
template-header that declares the template parameters, just   like you
do it for any other member.

  template<class T>
    int A<T>::a;


| 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?).

A<void> is a -specialization- so you first need to provide the
general definition above; then you go on requesting either the whole
the explicit specialization or you just request the explicit
specialization of that static data member. 

| 9.4.2 says this code is valid:
| 
| struct B { int b; } // the "false" definition of B::b

There is nothing named '"false" definition'.  The above is a
declaration.

| 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.

OK.  See above for a solution.


The PR could be closed.  This is more a question to be asked on
comp.lang.c++.moderated than a bug with the compiler.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14132


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]