https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
Bug ID: 67632 Summary: explicit instantiation omits copy constructor and others Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlink at drw dot com Target Milestone: --- When I compile the follow test case with g++ -std=c++11 -c, and view the output with nm, it shows that the std::unordered_map copy constructor is never emitted: % cat t.cc #include <unordered_map> template class std::unordered_map<int, int>; % g++ -std=c++11 -c t.cc % If I compile the following and link it with the above, I'll get the undefined reference: % cat x.cc #include <unordered_map> extern template class std::unordered_map<int, int>; std::unordered_map<int, int> copy( const std::unordered_map<int, int> & a) { return a; } main() {} % g++ -std=c++11 t.o x.cc /tmp/cc0dF94P.o: In function `copy(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&)': x.cc:(.text+0x1f): undefined reference to `std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >::unordered_map(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&)' collect2: error: ld returned 1 exit status This seems like a clear bug, right? Either the explicit instantiation should emit everything, or the use of extern template should know what still needs to be emitted locally.