https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68070
Bug ID: 68070 Summary: Undefined reference to default constructor of member template class Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: frrrwww at gmail dot com Target Milestone: --- Hello, When compiling the following simple program with `g++ prog.cc -Wall -Wextra -std=c++14` ----- #include <vector> template<typename Value> struct A { A() = default; std::vector<Value> m_content; }; void func(A<int> a = {}) { } int main() { func(); } ----- We get the following error: ----- /tmp/ccr6nbUo.o: In function `main': prog.cc:(.text+0x1b): undefined reference to `std::vector<int, std::allocator<int> >::vector()' collect2: error: ld returned 1 exit status ----- That error happens on gcc 4.9, 5.2 and 6.0, it does not happen on clang for this specific code. An alternative version of the code: ----- #include <vector> template<typename Value> struct A { A() = default; A(int) {} std::vector<Value> m_content; }; struct B { A<int> a; }; void func(B b = {}) { } int main() { func(); } ----- gets this error: ----- /tmp/ccvOFE5O.o: In function `main': prog.cc:(.text+0x33): undefined reference to `A<int>::A()' collect2: error: ld returned 1 exit status -----