https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86138
--- Comment #5 from Christian Franke <franke at computer dot org> --- (In reply to Jonathan Wakely from comment #4) > (In reply to Christian Franke from comment #3) > > > The extern templates are disabled because std::basic_string has additional > > > member functions in C++17 mode, and they're not instantiated in the > > > library. > > > By disabling the explicit instantiation declarations the compiler will > > > emit > > > definitions for the C++17-only member functions. > > This has no effect due to the bogus specialization in basic_string.h (see > > patch below). > > What's bogus about it? Here a simple example which demonstrates the same situation: $ cat bug.cpp template<typename T> void f(T & x) { x = T(); } #ifndef FIXED template<> void f(int &); // no visible implementation => same effect as extern template below! #endif #if __cplusplus <= 201402L extern template void f(int &); #endif void call_f(int & i) { f(i); } $ g++ -std=c++14 -c -o bug-14.o bug.cpp $ g++ -std=c++17 -c -o bug-17.o bug.cpp $ g++ -std=c++17 -DFIXED -c -o bug-17-fixed.o bug.cpp $ diff -qs bug-14.o bug-17.o ; diff -qs bug-17.o bug-17-fixed.o Files bug-14.o and bug-17.o are identical Files bug-17.o and bug-17-fixed.o differ $ nm -C bug-17.o | grep ' [TU] ' U void f<int>(int&) 0000000000000000 T call_f(int&) $ nm -C bug-17-fixed.o | grep ' [TU] ' 0000000000000000 T void f<int>(int&) 0000000000000000 T call_f(int&) > This patch won't be accepted, it's papering over some other problem not > fixing anything. I disagree. This should be fixed anyway, see above.