https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109464
--- Comment #5 from LIU Hao <lh_mouse at 126 dot com> --- Additional information: I tried splitting the two class templates into two separate .cpp files, so the explicit instantiation of `basic_shallow_string<char>` should not be subject to the instantiation of `basic_cow_string<char>`. This made GCC emit the constructor correctly (checked by examining assembly), but still failed to the very same undefined reference. At the moment, a temporary workaround is to mark the constructor of `basic_shallow_string` as `always_inline`. This works for GCC 10, 11 and 12. Haven't checked GCC 9 as it's no longer available from APT sources of my current machine.