This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12830] New: Static template member variable not instantiated
- From: "troyer at itp dot phys dot ethz dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Oct 2003 19:48:27 -0000
- Subject: [Bug c++/12830] New: Static template member variable not instantiated
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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();
}