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++/12830] New: Static template member variable not instantiated


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Static template member variable not instantiated
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: troyer at itp dot phys dot ethz dot ch
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.0.0
  GCC host triplet: powerpc-apple-darwin7.0.0
GCC target triplet: powerpc-apple-darwin7.0.0

The following code does not link, but gives the error:
/usr/bin/ld: Undefined symbols:
B<int>::zero_

Here is the source code, extracted from the Boost uBlas library, compiled without any compiler 
flags on MacOS 10.3:

template<class D>
struct A  {
  const D& derived() const {return *static_cast<const D*> (this);}
};

template<class T>
class B : public A<B<T> > {
public:
  T f() const { return zero_;  }
private:
  static T zero_;
};

template<class T> 
T B<T>::zero_ = 0;

int main()
{
  B<int> matrix;
  return matrix.derived().f();
}


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