From patchwork Sat Oct 15 20:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp771141wrs; Sat, 15 Oct 2022 13:23:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NeMzDt78yGvkSOvlUvzjuFQOotLH9rldKGpDI6OkkcSMK5vNCwHLERHbpnqgVfXU7cqea X-Received: by 2002:a17:907:3ea4:b0:78e:25e2:c33b with SMTP id hs36-20020a1709073ea400b0078e25e2c33bmr2960444ejc.603.1665865394567; Sat, 15 Oct 2022 13:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665865394; cv=none; d=google.com; s=arc-20160816; b=nMDIgxn4G7iPsq3c0kxKSV0hfINJFBa8Y+3kf6DiREH3mTt4vR6YOmL+6de89vUpde 6/qm56MEXm8/IOeNtlIvJfgAZDGP/aPOJJ4lFntzGpvQXt5o/TkinOW/zalZSKOrcm/n 5UILqOBdNvJIZyuPNicT+PUHcxVlXypMu9riz+ifq1qIwQOc/6V9zq5O6MtEqKmt4AH8 SF5zgDwqdgk6khVLYMxH97WSeXzEQCjU4J+yp+tMjlFLxFDeI5JjNT8U0GqQP0AhTU9M otf0KI0y/oJcPKGUxC0iZJAsQhJv06nun4NV7ir961We5sHhdpLuP3TEa+cBbZxPK/ph RjyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=FHi2gj5Kz3lFsmneidEn6SE/p3+5Z+NMav9qBk3nVt4=; b=kjSxCKR5dVlF04UCLGBURle0Dlt0W763hzqaQkI1wOsjS0X1KpYKMeEaZkLnsdULkq E33Ykt8NSX5EzESG2TKw2WrLBzqpvfAhPeKBRSxjF1xNY6PboZLyv1jUBU1fGxn51Ius b6crgft71VIOIsyAcg8LJMvE3RcE2tw/u4sXQucTT8EMCa4sKcbfcPr6J+usgosWbopb d+/sWtsqGXw/Nl2gGfx8wx5SwAHLGAM+9IgLoJ9bP9Rw2FC2X8NuBrOdvJ/x9mcDtalz i1XvX+8Z5yz4im8RUBslUKffDcNHERrlnoilVBX69oE/CJFsSCE3Q5H4X3GDUC/ioHXC a2qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vs8ZFCMI; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ga13-20020a1709070c0d00b0073daf6b44a5si5295995ejc.775.2022.10.15.13.23.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Oct 2022 13:23:14 -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=vs8ZFCMI; 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 631513857811 for ; Sat, 15 Oct 2022 20:22:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 631513857811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665865378; bh=FHi2gj5Kz3lFsmneidEn6SE/p3+5Z+NMav9qBk3nVt4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vs8ZFCMIuzbOykDqYjQGUTSfsR7uaaLjI97/x2PdfRHkYXA6w+GeaHZG7pGnnbBGh TezssrirkRIVILHZ6dx/36msmJ0l5XBWvOejAK/MNmRx+lNVOI6AiRSOx98R+wx1i1 QjyimDv6Nya7RWoNwcoroXOhtBVIL4/pwJFTmyqQ= 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 B357C3858D1E for ; Sat, 15 Oct 2022 20:22:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B357C3858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-TXAIRWcDOByKpFAwLa3E0g-1; Sat, 15 Oct 2022 16:22:12 -0400 X-MC-Unique: TXAIRWcDOByKpFAwLa3E0g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC770185A792; Sat, 15 Oct 2022 20:22:11 +0000 (UTC) Received: from localhost (unknown [10.33.36.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95BB2AE7B8; Sat, 15 Oct 2022 20:22:11 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix uses_allocator_construction args for cv pair (LWG 3677) Date: Sat, 15 Oct 2022 21:22:10 +0100 Message-Id: <20221015202210.2687628-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 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 autolearn=ham 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely 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?1746786471657064682?= X-GMAIL-MSGID: =?utf-8?q?1746786471657064682?= This issue is Tentatively Ready, and the resolution seems obviously correct so we can do it now. Tested powerpc64le-linux. Pushed to trunk. -- >8 -- The _Std_pair concept uses in handles const qualified pairs, but not volatile qualified. That's because it just uses __is_pair which is specialized for const pairs. This removes the partial specialization __is_pair>, so that __is_pair is now only true for cv-unqualified pairs. Then _Std_pair needs to explicitly use remove_cv_t for the argument to __is_pair. The other use of __is_pair is in map::insert(Pair&&) which doesn't want to handle volatile so should just use remove_const_t. libstdc++-v3/ChangeLog: * include/bits/stl_map.h (map::insert(Pair&&)): Use remove_const_t on argument to __is_pair. * include/bits/stl_pair.h (__is_pair>): Remove partial specialization. * include/bits/uses_allocator_args.h (_Std_pair): Use remove_cv_t as per LWG 3677. * testsuite/20_util/uses_allocator/lwg3677.cc: New test. --- libstdc++-v3/include/bits/stl_map.h | 2 +- libstdc++-v3/include/bits/stl_pair.h | 3 -- .../include/bits/uses_allocator_args.h | 2 +- .../20_util/uses_allocator/lwg3677.cc | 52 +++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 9c2b0745673..83c579aaedc 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { #if __cplusplus >= 201703L using _P2 = remove_reference_t<_Pair>; - if constexpr (__is_pair<_P2>) + if constexpr (__is_pair>) if constexpr (is_same_v>) if constexpr (__usable_key) { diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index d0f07b09d34..195167019b7 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -889,9 +889,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline constexpr bool __is_pair> = true; - - template - inline constexpr bool __is_pair> = true; #endif /// @cond undocumented diff --git a/libstdc++-v3/include/bits/uses_allocator_args.h b/libstdc++-v3/include/bits/uses_allocator_args.h index ef5c4fffb70..77e48602aac 100644 --- a/libstdc++-v3/include/bits/uses_allocator_args.h +++ b/libstdc++-v3/include/bits/uses_allocator_args.h @@ -44,7 +44,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION template - concept _Std_pair = __is_pair<_Tp>; + concept _Std_pair = __is_pair>; /** @addtogroup allocators * @{ diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc new file mode 100644 index 00000000000..649b98d3922 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++20 } } + +#include +#include + +struct UsesAlloc +{ + using allocator_type = std::allocator; + + bool passed_alloc; + + UsesAlloc(int) : passed_alloc(false) { } + + UsesAlloc(int, std::allocator) : passed_alloc(true) { } +}; + +using Pair = std::pair; + +void +test_const() +{ + std::allocator a; + int i = 0; + auto p = std::make_obj_using_allocator(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +void +test_volatile() +{ + std::allocator a; + int i = 0; + auto p = std::make_obj_using_allocator(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +void +test_const_volatile() +{ + std::allocator a; + int i = 0; + auto p = std::make_obj_using_allocator(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +int main() +{ + test_const(); + test_volatile(); + test_const_volatile(); +}