http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47544
Summary: c++0x linker does not find =default constructor for explicitly instantiated template Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: tspit...@ieee.org When compiling the file a.cpp below, the linker does not find the constructor of an explicitly instantiated template if the constructor is defined using = default. $ cat a.cpp template <typename T> struct s { s(); }; extern template struct s<int>; template <typename T> s<T>::s() = default; //s<T>::s() {} // gives no error template struct s<int>; int main() { s<int> a; } $ g++-4.5 -std=c++0x a.cpp /tmp/cc4PTe2q.o(.text+0x10): In function `main': : undefined reference to `s<int>::s()' collect2: ld returned 1 exit status $ g++-4.5 -v Using built-in specs. COLLECT_GCC=g++-4.5 COLLECT_LTO_WRAPPER=/home/eeyts/root/libexec/gcc/x86_64-unknown-linux-gnu/4.5.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.5.2/configure --prefix=/home/eeyts/root --disable-shared --enable-threads=posix --enable-__cxa_atexit --enable-libgomp --disable-libunwind-exceptions --enable-languages=c,c++,ada --with-gmp=/home/eeyts/root --with-mpfr=/home/eeyts/root --with-mpc=/home/eeyts/root --with-host-libstdcxx=/usr/lib64/libstdc++.so.6 --with-ppl=/home/eeyts/root --with-cloog=/home/eeyts/root --with-libelf=/home/eeyts/root --program-suffix=-4.5 Thread model: posix gcc version 4.5.2 (GCC) $ ld -v GNU ld version 2.15.92.0.2 20040927