[Bug c++/12830] New: Static template member variable not instantiated
troyer at itp dot phys dot ethz dot ch
gcc-bugzilla@gcc.gnu.org
Wed Oct 29 19:53:00 GMT 2003
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();
}
More information about the Gcc-bugs
mailing list