From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 96B2138582BC for ; Wed, 24 Aug 2022 18:38:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96B2138582BC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kuhHzAp1fUTbZsFGiIbHMHk5yBNprXFlALtRIwmRyR8=; b=SVxEe2+7yPwtR/HvAXpnEF+q78o1XLTKfsq+O1j1qqOiJOuZbTUGwCNin+M+m6OK0WIRb8 hdgJCLBm9ppsBaj6R4QitmQfija22pmh6acuUgXX/ob1AKSg3mRM3w9fufhVKj/HmXeLAt zaTysGcKo7UhsJWFp9Dr+RZSXHiyVss= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-592-RG9jro6wOJSLOC-ZcYYt9w-1; Wed, 24 Aug 2022 14:38:19 -0400 X-MC-Unique: RG9jro6wOJSLOC-ZcYYt9w-1 Received: by mail-qk1-f199.google.com with SMTP id bj2-20020a05620a190200b006bba055ab6eso15368472qkb.12 for ; Wed, 24 Aug 2022 11:38:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=kuhHzAp1fUTbZsFGiIbHMHk5yBNprXFlALtRIwmRyR8=; b=YlR8BgVpEIEYcW2LgEpEdRe66Zh2x9RbdMXT+nZqzxKlJHzahdf6CQQzP1/tMr5qRM hORGQgs5zUjpMQllyWq+XOx4kmjEqBAZ/a5hA/utKe4M3VrpieEFFeanIOVt5uSCPHaw Se/qnIW196hWpsC6VwoqTCqYAEXQbm6HTpVqT9irDUash69sjHxr6HiyZ4xbtiJeNfbw 3wMhvtHG1KZA4PZerpvhLDh1pax3/IsyQr2WtDqeO4KNWDHukjc8rdysuItgfAOAFQwf 7tPUXvFdDb5+mS5btslP+SdVJmMYNd6d2vuJDcYe/qMcHYBQij6kFZCwiv7gh4gMBRa3 7r6Q== X-Gm-Message-State: ACgBeo2aAG4IIu3gIzO58754JzIFAfJpfhB/s9LmMbjIVrd4Yc8ztFLx aFFC7ZNbCeoIlk51yq34yyBkXiPq5FyBLLBKriwR8NB6TmIfUi2d6agYgj9anks0mmi1/fQRFVB FF4bQoCrFL6b++ZX1VIbGMxpVhxjwmiI= X-Received: by 2002:ad4:5bc3:0:b0:482:5a89:c107 with SMTP id t3-20020ad45bc3000000b004825a89c107mr389490qvt.84.1661366298500; Wed, 24 Aug 2022 11:38:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hBtayGLlTUDir4RuOhR+EqmBrO+bFyJsDzjzf5A5tqwzAqfrMm1diqIL0C+eacJgS/kN6e/9OyqHRPZHGo6I= X-Received: by 2002:ad4:5bc3:0:b0:482:5a89:c107 with SMTP id t3-20020ad45bc3000000b004825a89c107mr389471qvt.84.1661366298239; Wed, 24 Aug 2022 11:38:18 -0700 (PDT) MIME-Version: 1.0 References: <20220824163644.1963933-1-ppalka@redhat.com> <3f7196b6-e7cc-e580-50f9-e768aa567c9e@idea> In-Reply-To: <3f7196b6-e7cc-e580-50f9-e768aa567c9e@idea> From: Jonathan Wakely Date: Wed, 24 Aug 2022 19:38:07 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Fix fallout from P2321R2 pair/tuple enhancements To: Patrick Palka Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 24 Aug 2022 at 18:00, Patrick Palka via Libstdc++ wrote: > > On Wed, 24 Aug 2022, Patrick Palka wrote: > > > r13-2159-g72886fcc626953 introduced some testsuite regressions in C++23 > > mode: > > > > FAIL: 20_util/pair/requirements/explicit_instantiation/1.cc (test for excess errors) > > FAIL: 20_util/tuple/53648.cc (test for excess errors) > > FAIL: 20_util/tuple/cons/noexcept_specs.cc (test for excess errors) > > FAIL: 20_util/tuple/requirements/explicit_instantiation.cc (test for excess errors) > > > > The test noexcept_specs.cc just needs to be updated to consider the > > additional converting constructors of tuple in C++23 mode, which happen > > to improve constructing from a const tuple rvalue containing rvalue > > reference elements (for the better, as far as I can tell). > > > > The other three tests fail because they explicitly instantiate a specialization > > of tuple whose elements are not all const swappable, which in C++23 mode now > > results in a hard error due to tuple's new const swap member function. Rather > > than XFAILing the tests in C++23 mode, this patch adds non-standard constraints > > to this member function so that we continue to accept such explicit instantiations. > > > > Tested on x86_64-pc-linux-gnu with and without --target_board=unix/-std=gnu++23, > > does this look OK for trunk? > > > > libstdc++-v3/ChangeLog: > > > > * include/std/tuple (tuple::swap const): Add is_swappable_v constraints. > > D'oh, pair's const swap needs the same workaround: OK for trunk, thanks for the quick fix. > > -- >8 -- > > libstdc++-v3/ChangeLog: > > * include/bits/stl_pair.h (pair::swap const): Add non-standard > is_swappable_v constraints. > * include/std/tuple (tuple::swap const): Likewise. > * testsuite/20_util/tuple/cons/noexcept_specs.cc: Update some > asserts in C++23 mode. > --- > libstdc++-v3/include/bits/stl_pair.h | 8 ++++ > libstdc++-v3/include/std/tuple | 9 ++++ > .../20_util/tuple/cons/noexcept_specs.cc | 41 +++++++++++++++++++ > 3 files changed, 58 insertions(+) > > diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h > index bffca0daf65..a65a4763c54 100644 > --- a/libstdc++-v3/include/bits/stl_pair.h > +++ b/libstdc++-v3/include/bits/stl_pair.h > @@ -213,10 +213,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > } > > #if __cplusplus > 202002L > + // As an extension, we constrain the const swap member function > + // in order to continue accepting explicit instantiation of tuple > + // specializations whose elements are not all const swappable. > + // Without this constraint, such an explicit instantiation would > + // also instantiate the ill-formed body of this function and yield > + // a hard error. This constraint shouldn't affect the behavior of > + // valid programs. > constexpr void > swap(const pair& __p) const > noexcept(__and_v<__is_nothrow_swappable, > __is_nothrow_swappable>) > + requires is_swappable_v && is_swappable_v > { > using std::swap; > swap(first, __p.first); > diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple > index 05433d5ae36..9d1abc2f80e 100644 > --- a/libstdc++-v3/include/std/tuple > +++ b/libstdc++-v3/include/std/tuple > @@ -1176,9 +1176,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > { _Inherited::_M_swap(__in); } > > #if __cplusplus > 202002L > + // As an extension, we constrain this const swap member function > + // in order to continue accepting explicit instantiation of tuple > + // specializations whose elements are not all const swappable. > + // Without this constraint, such an explicit instantiation would > + // also instantiate the ill-formed body of this function and > + // yield a hard error. This constraint shouldn't affect the behavior of > + // valid programs. > constexpr void > swap(const tuple& __in) const > noexcept(__and_v<__is_nothrow_swappable...>) > + requires (is_swappable_v && ...) > { _Inherited::_M_swap(__in); } > #endif // C++23 > }; > @@ -1730,6 +1738,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > swap(const tuple& __in) const > noexcept(__and_v<__is_nothrow_swappable, > __is_nothrow_swappable>) > + requires is_swappable_v && is_swappable_v > { _Inherited::_M_swap(__in); } > #endif // C++23 > }; > diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc > index 6044a377348..a326d1bc228 100644 > --- a/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc > +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc > @@ -503,7 +503,17 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(!std::is_nothrow_constructible::value, ""); > static_assert(!std::is_nothrow_constructible::value, ""); > static_assert(!std::is_nothrow_constructible>::value, ""); > +#if __cplusplus > 202002L > + // C++23 extended tuple's constructor overload set as part of P2321R2, after > + // which its converting constructors more accurately forward the elements > + // from a non-const tuple lvalue and from a const tuple rvalue. In particular > + // for the below test we now forward int&& as an rvalue reference instead of > + // as an lvalue reference, which means we now select the noexcept B(int&&) > + // ctor instead of the non-noexcept B(const int&) ctor. > + static_assert(std::is_nothrow_constructible>::value, ""); > +#else > static_assert(!std::is_nothrow_constructible>::value, ""); > +#endif > > static_assert(test_trait::is_nothrow_convertible::value,""); > static_assert(!test_trait::is_nothrow_convertible::value,""); > @@ -515,7 +525,13 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(!test_trait::is_nothrow_convertible::value,""); > static_assert(!test_trait::is_nothrow_convertible::value,""); > static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); > +#if __cplusplus > 202002L > + // See the note about P2321R2 above. > + static_assert(test_trait::is_nothrow_convertible,BT>::value,""); > +#else > static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); > +#endif > + > > > static_assert(!std::is_nothrow_constructible::value, ""); > @@ -528,7 +544,12 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible>::value, ""); > +#if __cplusplus > 202002L > + // See the note about P2321R2 above. > + static_assert(!std::is_nothrow_constructible>::value, ""); > +#else > static_assert(std::is_nothrow_constructible>::value, ""); > +#endif > > static_assert(!test_trait::is_nothrow_convertible::value,""); > static_assert(test_trait::is_nothrow_convertible::value,""); > @@ -540,7 +561,12 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(test_trait::is_nothrow_convertible::value,""); > static_assert(test_trait::is_nothrow_convertible::value,""); > static_assert(test_trait::is_nothrow_convertible,BT>::value,""); > +#if __cplusplus > 202002L > + // See the note about P2321R2 above. > + static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); > +#else > static_assert(test_trait::is_nothrow_convertible,BT>::value,""); > +#endif > > /* explicit */ > static_assert(std::is_nothrow_constructible::value, ""); > @@ -553,7 +579,12 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(!std::is_nothrow_constructible::value, ""); > static_assert(!std::is_nothrow_constructible::value, ""); > static_assert(!std::is_nothrow_constructible>::value, ""); > +#if __cplusplus > 202002L > + // See the note about P2321R2 above. > + static_assert(std::is_nothrow_constructible>::value, ""); > +#else > static_assert(!std::is_nothrow_constructible>::value, ""); > +#endif > > static_assert(!std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible::value, ""); > @@ -565,7 +596,12 @@ namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible>::value, ""); > +#if __cplusplus > 202002L > + // See note about P2321R2 above. > + static_assert(!std::is_nothrow_constructible>::value, ""); > +#else > static_assert(std::is_nothrow_constructible>::value, ""); > +#endif > > static_assert(!test_trait::is_nothrow_convertible::value,""); > static_assert(test_trait::is_nothrow_convertible::value,""); > @@ -884,7 +920,12 @@ namespace ThrowMoveNothrowConversion > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible::value, ""); > static_assert(std::is_nothrow_constructible>::value, ""); > +#if __cplusplus > 202002L > + // See the note about P2321R2 above. > + static_assert(!std::is_nothrow_constructible>::value, ""); > +#else > static_assert(std::is_nothrow_constructible>::value, ""); > +#endif > > static_assert(test_trait::is_nothrow_convertible::value,""); > static_assert(test_trait::is_nothrow_convertible::value,""); > -- > 2.37.2.382.g795ea8776b >