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
template class std::unordered_map;
% 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
extern template class std::unordered_map;
std::unordered_map copy(
const std::unordered_map & a) { return a; }
main() {}
% g++ -std=c++11 t.o x.cc
/tmp/cc0dF94P.o: In function `copy(std::unordered_map,
std::equal_to, std::allocator > > const&)':
x.cc:(.text+0x1f): undefined reference to `std::unordered_map, std::equal_to, std::allocator >
>::unordered_map(std::unordered_map,
std::equal_to, std::allocator > > 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.