From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 4F87A396E45E; Wed, 17 Jun 2020 19:24:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F87A396E45E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592421857; bh=xbxcvDQL5vmtEuhQGG7trzaLY8ExDQ6NcyaAdRdPzag=; h=From:To:Subject:Date:From; b=SpuJQ0HkSuCt+urcAf/wiIva07jfDaxzBtia8PfY7DT3NyjgO9iNhipfpdtson3vE Z0mAV0qT3LF/jogaedgM3wcIBq/iWxphPsnBAOzayEqf4OMAfoHIava+MM3/vv1A9T QGn9A4z2Q57rpAxWC3yvPM1lu8WlA0I0O6+D0JmA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: Fix use of is_nothrow_assignable_v in X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: 7f327e8765c25552a1a6ae7d8747f74786f243dd X-Git-Newrev: 05779e2c89e06d09a6b685797e87723f7906a5ce Message-Id: <20200617192417.4F87A396E45E@sourceware.org> Date: Wed, 17 Jun 2020 19:24:17 +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: Wed, 17 Jun 2020 19:24:17 -0000 https://gcc.gnu.org/g:05779e2c89e06d09a6b685797e87723f7906a5ce commit 05779e2c89e06d09a6b685797e87723f7906a5ce Author: Patrick Palka Date: Mon Mar 2 19:39:13 2020 -0500 libstdc++: Fix use of is_nothrow_assignable_v in We are passing a value type as the first argument to is_nothrow_assignable_v, but the result of that is inevitably false. Since this predicate is a part of the condition that guards the corresponding optimizations for these algorithms, this bug means these optimizations are never used. We should be passing a reference type to is_nothrow_assignable_v instead. libstdc++-v3/ChangeLog: * include/bits/ranges_uninitialized.h (uninitialized_copy_fn::operator()): Pass a reference type as the first argument to is_nothrow_assignable_v. (uninitialized_copy_fn::operator()): Likewise. (uninitialized_move_fn::operator()): Likewise. Return an in_out_result with the input iterator stripped of its move_iterator. (uninitialized_move_n_fn::operator()): Likewise. (uninitialized_fill_fn::operator()): Pass a reference type as the first argument to is_nothrow_assignable_v. (uninitialized_fill_n_fn::operator()): Likewise. Diff: --- libstdc++-v3/ChangeLog | 13 +++++++++++++ libstdc++-v3/include/bits/ranges_uninitialized.h | 24 ++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 640c5be90ab..45ff06d4ea7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2020-03-04 Patrick Palka + + * include/bits/ranges_uninitialized.h + (uninitialized_copy_fn::operator()): Pass a reference type as the first + argument to is_nothrow_assignable_v. + (uninitialized_copy_fn::operator()): Likewise. + (uninitialized_move_fn::operator()): Likewise. Return an in_out_result + with the input iterator stripped of its move_iterator. + (uninitialized_move_n_fn::operator()): Likewise. + (uninitialized_fill_fn::operator()): Pass a reference type as the first + argument to is_nothrow_assignable_v. + (uninitialized_fill_n_fn::operator()): Likewise. + 2020-03-03 Jonathan Wakely PR libstdc++/94013 diff --git a/libstdc++-v3/include/bits/ranges_uninitialized.h b/libstdc++-v3/include/bits/ranges_uninitialized.h index 01e1cad646c..f97a07a9b4a 100644 --- a/libstdc++-v3/include/bits/ranges_uninitialized.h +++ b/libstdc++-v3/include/bits/ranges_uninitialized.h @@ -269,7 +269,7 @@ namespace ranges if constexpr (sized_sentinel_for<_ISent, _Iter> && sized_sentinel_for<_OSent, _Out> && is_trivial_v<_OutType> - && is_nothrow_assignable_v<_OutType, + && is_nothrow_assignable_v<_OutType&, iter_reference_t<_Iter>>) { auto __d1 = ranges::distance(__ifirst, __ilast); @@ -316,7 +316,7 @@ namespace ranges using _OutType = remove_reference_t>; if constexpr (sized_sentinel_for<_Sent, _Out> && is_trivial_v<_OutType> - && is_nothrow_assignable_v<_OutType, + && is_nothrow_assignable_v<_OutType&, iter_reference_t<_Iter>>) { auto __d = ranges::distance(__ofirst, __olast); @@ -354,13 +354,15 @@ namespace ranges if constexpr (sized_sentinel_for<_ISent, _Iter> && sized_sentinel_for<_OSent, _Out> && is_trivial_v<_OutType> - && is_nothrow_assignable_v<_OutType, + && is_nothrow_assignable_v<_OutType&, iter_rvalue_reference_t<_Iter>>) { auto __d1 = ranges::distance(__ifirst, __ilast); auto __d2 = ranges::distance(__ofirst, __olast); - return ranges::copy_n(std::make_move_iterator(__ifirst), - std::min(__d1, __d2), __ofirst); + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(__ifirst), + std::min(__d1, __d2), __ofirst); + return {std::move(__in).base(), __out}; } else { @@ -404,12 +406,14 @@ namespace ranges using _OutType = remove_reference_t>; if constexpr (sized_sentinel_for<_Sent, _Out> && is_trivial_v<_OutType> - && is_nothrow_assignable_v<_OutType, + && is_nothrow_assignable_v<_OutType&, iter_rvalue_reference_t<_Iter>>) { auto __d = ranges::distance(__ofirst, __olast); - return ranges::copy_n(std::make_move_iterator(__ifirst), - std::min(__n, __d), __ofirst); + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(__ifirst), + std::min(__n, __d), __ofirst); + return {std::move(__in).base(), __out}; } else { @@ -436,7 +440,7 @@ namespace ranges { using _ValueType = remove_reference_t>; if constexpr (is_trivial_v<_ValueType> - && is_nothrow_assignable_v<_ValueType, const _Tp&>) + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) return ranges::fill(__first, __last, __x); else { @@ -469,7 +473,7 @@ namespace ranges { using _ValueType = remove_reference_t>; if constexpr (is_trivial_v<_ValueType> - && is_nothrow_assignable_v<_ValueType, const _Tp&>) + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) return ranges::fill_n(__first, __n, __x); else {