[Bug libstdc++/125969] Explicit instantiations for std::string are disabled by -D_GLIBCXX_ASSERTIONS

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 24 13:30:44 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125969

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A reliable solution would be to use abi_tag on all std::string functions with
assertions, and export both symbols, with and without the tag. Then we wouldn't
need to disable the explicit instantiation declarations when assertions are
enabled, the callers would just link to the explicit instantiation definitions
with tags.

This is what libc++ does for its hardened preconditions.

But it would add a lot of new symbols to the library, for unclear benefit. In
most cases, small functions get inlined and the assertions are either enabled
(or disabled) as appropriate for the current TU.


More information about the Gcc-bugs mailing list