From patchwork Wed Aug 24 16:36:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1507239wro; Wed, 24 Aug 2022 09:38:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SnXKiZEzYWDRgDh0rin4kUJk1DVst7FYsVQB18nYh0V2KEFPY9ER003L2YHcJlrBAkZLT X-Received: by 2002:a17:906:4787:b0:737:2a03:6dd6 with SMTP id cw7-20020a170906478700b007372a036dd6mr3483286ejc.476.1661359089652; Wed, 24 Aug 2022 09:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661359089; cv=none; d=google.com; s=arc-20160816; b=yLoxO76qpA/WVI31qdDHGAAkPdIrxmS2dao2tKpdc5OhRsZ5+hXgOqo+bCo1ibBmcM 6tP/B/CYkWaZatqOlLHB6jysnkGEA97qsO1RGnuzA4TMnyyrfGIK0pmQFgBCeRd4+31+ MFKKuB4ncL8UlihVwTxnaYd2jtm6f2WJFSIsXxS7ycrtgIi92eRhOlrxtYtE6J7wtjeg r+RZEGhTCKAQQ/WlIDhqJW2LUAuDyUhKKNZSlFF6HS9r9c4x5aS8mABA1X8EObvfvAT2 BHES0QOaRz9zXjMzV5/XZHSJeJnpkEjdAAbxVGG7NwI9oK5sV5U446ytPiSJQe0IDdxJ +OJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=kXV0MJ1QroU71p7jmcZz8IFu/aOVkNScvTLWHRLQGHo=; b=o6clPcl5EWYeysnrBp3X/EO+6hQwhccZXMpVFWP1BUQH2YywvTPVuGZ4orvL88JFFH 7Y7jdHKaIjbbRY/AqLSv+c6+W7310JtIvZzMYU2shaiNL2Y2X2m8c4EbAwqMfWc7BznF BxaLnXhcl68fRzNNO9W3V3JZT1Fd0ULwR1aGM3Cjrq0rgtuv4H/Hk/SoWEeK+pkjrDTi W3SFx5iwxmwWP+1FMEywL7tADVkCnRKtqOTJkx+Int7L0UM6muwpmUZh4gWMAZjOYfkO 46gphq3tpSTZ79RX8zmPKYawdelsfj98/w65TNVEwoXa2tPI2CufbvvYUlwTTRuGG+hM TA+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MB+QuvSB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nb37-20020a1709071ca500b007311b45e4bcsi3036216ejc.692.2022.08.24.09.38.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 09:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MB+QuvSB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBAEF3851C0B for ; Wed, 24 Aug 2022 16:37:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBAEF3851C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661359067; bh=kXV0MJ1QroU71p7jmcZz8IFu/aOVkNScvTLWHRLQGHo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MB+QuvSBNQk7G0K5dDw94vDKaE73DsbMYh/dF+GvDi46kIExrXnx6u6NFIDnCQjG3 RLAv1sk4t9WYVwEt3DrJJYnCcci7jX6HmzkevZcLXRs/D6TJftpx7mDupsT/KrLF/f RaF39eAIJWXEJpJ54PomAJ6u3AiraNjstlaIg974= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B8DF7385C401 for ; Wed, 24 Aug 2022 16:36:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8DF7385C401 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-547--R6J6Y-UOlSsJW7_cV4ZyQ-1; Wed, 24 Aug 2022 12:36:51 -0400 X-MC-Unique: -R6J6Y-UOlSsJW7_cV4ZyQ-1 Received: by mail-qk1-f200.google.com with SMTP id bp11-20020a05620a458b00b006bbeffab91dso10785032qkb.11 for ; Wed, 24 Aug 2022 09:36:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=kXV0MJ1QroU71p7jmcZz8IFu/aOVkNScvTLWHRLQGHo=; b=JXAmRnrIXO+/MnU8r2X6DJh2zhpp4iAbJlQdG7xZBOQzItEEIcIzYiDgCdPaKjoeQ4 ZOGaXEiDAcQlp+WBg84pXcg+JdECf+i1u66j8CQdFNL+AuIxVpFnClRyb//qzdhNOR8i +LRDvEXefILS/HltzYVKU+jarREgpuoK+RrdSNruPyU5xSn5Cff04C4tARN2gIzXMdF8 gJ9UFBcjQnXFsJa/FXkZfA2RHaiT0Y2GAS23n/V/uJ5ZDkp8gzsmNYI+G46EHuxcqhy9 z4jjMAMzhTcD1gtPzT6qY3bAmHcpVE8FfBJ7p55Rg3CaDJY9Oiz5bP9e6cFYBmD6/T97 jy6A== X-Gm-Message-State: ACgBeo2gqsEPSST7gHhL4HL2fJZf8X1MvkFVWPjhraGB/WIy740JHRI5 YgrSq155jdJlUJtfGUPIuqlWtWUfv7co/B4TyM71jShjvko7S2bzLNLC54u1jcrBQ9YQ3JrJ1Pd zA30ZVqlK11+Adnk9wSamf69gdMKU8AhtAZ1Aq9Fc+sUPDzD3GEDCadeVnCvtKHUBri4= X-Received: by 2002:ad4:5d61:0:b0:496:b107:b7cb with SMTP id fn1-20020ad45d61000000b00496b107b7cbmr25925418qvb.53.1661359011086; Wed, 24 Aug 2022 09:36:51 -0700 (PDT) X-Received: by 2002:ad4:5d61:0:b0:496:b107:b7cb with SMTP id fn1-20020ad45d61000000b00496b107b7cbmr25925321qvb.53.1661359009730; Wed, 24 Aug 2022 09:36:49 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id d22-20020ac86696000000b00342e86b3bdasm12672806qtp.12.2022.08.24.09.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 09:36:49 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix fallout from P2321R2 pair/tuple enhancements Date: Wed, 24 Aug 2022 12:36:44 -0400 Message-Id: <20220824163644.1963933-1-ppalka@redhat.com> X-Mailer: git-send-email 2.37.2.382.g795ea8776b MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.3 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_LOW, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742061268753907852?= X-GMAIL-MSGID: =?utf-8?q?1742061268753907852?= 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. * testsuite/20_util/tuple/cons/noexcept_specs.cc: Adjust some asserts for C++23 mode. --- libstdc++-v3/include/std/tuple | 9 ++++ .../20_util/tuple/cons/noexcept_specs.cc | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+) 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,"");