https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103919
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:4c64143f32642d22590959704e2ec6c686d745ff commit r11-9435-g4c64143f32642d22590959704e2ec6c686d745ff Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Jan 5 15:16:33 2022 +0000 libstdc++: Fix overconstrained std::string constructor [PR103919] The C++17 basic_string(const T&, size_t, size_t) constructor is overconstrained, so it can't be used for a NTBS and a temporary string gets constructed (potentially allocating memory). There is no corresponding constructor taking an NTBS, so no need to disambiguate from it. Accepting an NTBS avoids the temporary (and potential allocation) and is what the standard requires. libstdc++-v3/ChangeLog: PR libstdc++/103919 * include/bits/basic_string.h (basic_string(const T&, size_t, size_t)): Relax constraints on string_view parameter. [!_GLIBCXX_USE_CXX11_ABI] (basic_string(const T&, size_t, size_t)): Likewise. * testsuite/21_strings/basic_string/cons/char/103919.cc: New test. (cherry picked from commit 6aa0859afaf28f4fb13121352225bc5877e02a44)