From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 3538A385780F; Tue, 20 Oct 2020 17:52:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3538A385780F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-8922] libstdc++: Implement LWG 3706 for COW strings X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: a8f4ed53b3b4c39d8a0a44da087856aedc08ac7a X-Git-Newrev: a109beccd84bf255d1b298d8c09d88022d06d4f3 Message-Id: <20201020175258.3538A385780F@sourceware.org> Date: Tue, 20 Oct 2020 17:52:58 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 17:52:58 -0000 https://gcc.gnu.org/g:a109beccd84bf255d1b298d8c09d88022d06d4f3 commit r10-8922-ga109beccd84bf255d1b298d8c09d88022d06d4f3 Author: Jonathan Wakely Date: Wed Oct 14 11:52:26 2020 +0100 libstdc++: Implement LWG 3706 for COW strings The basic_string deduction guides are defined for the old ABI, but the tests are currently disabled. This is because a single case fails when using the old ABI, which is just because LWG 3706 isn't implemented for the old ABI. That can be done easily, and the tests can be enabled. libstdc++-v3/ChangeLog: * include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI] (basic_string(const _CharT*, const _Alloc&)): Constrain to require an allocator-like type to fix CTAD ambiguity (LWG 3706). Define inline. * include/bits/basic_string.tcc [!_GLIBCXX_USE_CXX11_ABI] (basic_string(const _CharT*, const _Alloc&)): Remove non-inline definition. * testsuite/21_strings/basic_string/cons/char/deduction.cc: Remove dg-skip-if. * testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc: Likewise. (cherry picked from commit dc38e255242192303ae463a913c060b426eb06c0) Diff: --- libstdc++-v3/include/bits/basic_string.h | 12 +++++++++++- libstdc++-v3/include/bits/basic_string.tcc | 8 -------- .../testsuite/21_strings/basic_string/cons/char/deduction.cc | 1 - .../21_strings/basic_string/cons/wchar_t/deduction.cc | 1 - 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index bc0c256b65e..bbab7b9d4d2 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -3605,12 +3605,22 @@ _GLIBCXX_END_NAMESPACE_CXX11 */ basic_string(const _CharT* __s, size_type __n, const _Alloc& __a = _Alloc()); + /** * @brief Construct string as copy of a C string. * @param __s Source C string. * @param __a Allocator to use (default is default allocator). */ - basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()); +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) : + __s + npos, __a), __a) + { } + /** * @brief Construct string as multiple characters. * @param __n Number of characters. diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index e370f439390..204a140a735 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -659,14 +659,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_dataplus(_S_construct(__s, __s + __n, __a), __a) { } - // TBD: DPG annotate - template - basic_string<_CharT, _Traits, _Alloc>:: - basic_string(const _CharT* __s, const _Alloc& __a) - : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) : - __s + npos, __a), __a) - { } - template basic_string<_CharT, _Traits, _Alloc>:: basic_string(size_type __n, _CharT __c, const _Alloc& __a) diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/deduction.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/deduction.cc index 6484ed43453..d05c4b776c3 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/deduction.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/deduction.cc @@ -17,7 +17,6 @@ // { dg-options "-std=gnu++17" } // { dg-do compile { target c++17 } } -// { dg-xfail-if "COW string missing deduction guides" { ! cxx11-abi } } #include #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc index 373b2b24bdd..1773be28e37 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc @@ -17,7 +17,6 @@ // { dg-options "-std=gnu++17" } // { dg-do compile { target c++17 } } -// { dg-xfail-if "COW string missing deduction guides" { ! cxx11-abi } } #include #include