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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>:

https://gcc.gnu.org/g:6aa0859afaf28f4fb13121352225bc5877e02a44

commit r12-6267-g6aa0859afaf28f4fb13121352225bc5877e02a44
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.
            * include/bits/cow_string.h (basic_string(const T&, size_t,
size_t)):
            Likewise.
            * testsuite/21_strings/basic_string/cons/char/103919.cc: New test.

Reply via email to