https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125955
Bug ID: 125955
Summary: [15 regressions] Extern template declarations for
basic_string are not respected
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: tkaminsk at gcc dot gnu.org
Target Milestone: ---
When compiling the following snippet in C++11 mode:
#include <string>
void foo() {
std::string s("sdfdsf", 20);
s.substr(10, 20);
s.append("Sdfsdf", 20);
}
The GCC-14 does not emit the definitions for substr/append method, and have
undefined symbols.
U _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
U _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
This is expected as we provide extern declaration for basic_string
specialization.
However, starting from GCC-15 the weak symbols for append/substr (and other
basic_string method) method are emitted, seemingly ignoring extern template
declaration:
0000000000000000 W
_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
0000000000000000 W
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
Live link: https://godbolt.org/z/v9jfqoPfr