From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id CF2763857821; Tue, 12 Oct 2021 10:59:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF2763857821 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9115] libstdc++: Fix CTAD for debug sequence containers X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: a9e07e1651a4a219602ef848fa891ba78733084f X-Git-Newrev: 822bd7f6a2fad3821f501d5a814a771a0c3a09fa Message-Id: <20211012105943.CF2763857821@sourceware.org> Date: Tue, 12 Oct 2021 10:59:43 +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, 12 Oct 2021 10:59:43 -0000 https://gcc.gnu.org/g:822bd7f6a2fad3821f501d5a814a771a0c3a09fa commit r11-9115-g822bd7f6a2fad3821f501d5a814a771a0c3a09fa Author: Jonathan Wakely Date: Tue Aug 17 18:19:27 2021 +0100 libstdc++: Fix CTAD for debug sequence containers This fixes some 23_containers/*/cons/deduction.cc failures seen with -std=c++17/-D_GLIBCXX_DEBUG, caused by non-immediate errors when substituting template arguments into an incorrect specialization of the std::__cxx1998 base class. This happens because the size_type member of the debug container is _Base_type::size_type, so is non-deducible, and the deduced types get substituted into _Base_type, triggering the static_assert that checks the allocator's value_type matches the container's. The solution is to make the C(size_type, const T&, const Alloc&) constructors of the debug sequence containers non-deducible. In order to make CTAD work again deduction guides that use std::size_t for the first argument are added. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/debug/deque (deque(size_type, const T&, const A&)): Prevent class template argument deduction and replace with a deduction guide. * include/debug/forward_list (forward_list(size_type, const T&, const A&)): Likewise. * include/debug/list (list(size_type, const T&, const A&)): Likewise. * include/debug/vector (vector(size_type, const T&, const A&)): Likewise. (cherry picked from commit 085c2f8f0e13d7c1515ce86755a52a31faf0cf47) Diff: --- libstdc++-v3/include/debug/deque | 7 ++++++- libstdc++-v3/include/debug/forward_list | 7 ++++++- libstdc++-v3/include/debug/list | 7 ++++++- libstdc++-v3/include/debug/vector | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index 227d083da04..4d19ec8f5fb 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -130,7 +130,7 @@ namespace __debug deque(size_type __n, const _Allocator& __a = _Allocator()) : _Base(__n, __a) { } - deque(size_type __n, const _Tp& __value, + deque(size_type __n, const __type_identity_t<_Tp>& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } #else @@ -650,6 +650,11 @@ namespace __debug typename = _RequireAllocator<_Allocator>> deque(_InputIterator, _InputIterator, _Allocator = _Allocator()) -> deque<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + deque(size_t, _Tp, _Allocator = _Allocator()) + -> deque<_Tp, _Allocator>; #endif template diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index 16f0531dce7..46e8eb90916 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -251,7 +251,7 @@ namespace __debug : _Base(__n, __al) { } - forward_list(size_type __n, const _Tp& __value, + forward_list(size_type __n, const __type_identity_t<_Tp>& __value, const allocator_type& __al = allocator_type()) : _Base(__n, __value, __al) { } @@ -843,6 +843,11 @@ namespace __debug typename = _RequireAllocator<_Allocator>> forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) -> forward_list<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + forward_list(size_t, _Tp, _Allocator = _Allocator()) + -> forward_list<_Tp, _Allocator>; #endif template diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 01fe43fc7df..5e0adad3aea 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -135,7 +135,7 @@ namespace __debug list(size_type __n, const allocator_type& __a = allocator_type()) : _Base(__n, __a) { } - list(size_type __n, const _Tp& __value, + list(size_type __n, const __type_identity_t<_Tp>& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } #else @@ -905,6 +905,11 @@ namespace __debug typename = _RequireAllocator<_Allocator>> list(_InputIterator, _InputIterator, _Allocator = _Allocator()) -> list<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + list(size_t, _Tp, _Allocator = _Allocator()) + -> list<_Tp, _Allocator>; #endif template diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 987bba17c2b..c6bdc3458eb 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -182,7 +182,7 @@ namespace __debug vector(size_type __n, const _Allocator& __a = _Allocator()) : _Base(__n, __a), _Safe_vector(__n) { } - vector(size_type __n, const _Tp& __value, + vector(size_type __n, const __type_identity_t<_Tp>& __value, const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } #else @@ -793,6 +793,11 @@ namespace __debug typename = _RequireAllocator<_Allocator>> vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) -> vector<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + vector(size_t, _Tp, _Allocator = _Allocator()) + -> vector<_Tp, _Allocator>; #endif } // namespace __debug