From patchwork Wed Mar 22 17:49:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 73589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2477653wrt; Wed, 22 Mar 2023 10:52:02 -0700 (PDT) X-Google-Smtp-Source: AK7set9mC/6gULV/HhDT2gJjA+yctjF9qpIJnm3/xIKizQXxbehpae45IF/ovKXtl9DGAvRcSnZZ X-Received: by 2002:a17:906:580c:b0:933:3aa7:57a7 with SMTP id m12-20020a170906580c00b009333aa757a7mr7351851ejq.49.1679507522137; Wed, 22 Mar 2023 10:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679507522; cv=none; d=google.com; s=arc-20160816; b=m/SeruWlPjHF0UUJYzW8k2XvyXG2+a3ukCyhoJJMQPABSRVSzUGd298Sz45U/e3IsE VSmMjLthmZe8diHlbksGmR3rCZfFmvn4cqU3UfVOOwl8gsZNZyx+hF8uDzGdaYeliG4c sGzsi+ecOY9Q4GUAtejcLVIAz8wWFuzl4wie4P4Z7l+ORYZXZe5ni1zQcGvEJ/45MBzl ADhQrHCrYz5H/P9/WZWQoOM33jlGiJF4/MfpUgjIsoqAF0lQCL6bRVM7Q06sxy00qU84 PWu8ZNsrLvpGHAiCoq7lj1eKORMxbVzf6oHqvN0OLwtAb1WSU/hTmXJ+q1p5mReHU2aN gLag== 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=CCVuVAa5yGs1kEKzZOsj/u/crx5jQDUC9l1s1UyAwxs=; b=Cd1SaLBTrJCQKfWiBhBVxN3kUYMqEHll1jzasDXXjaiyXQWOH0Q4k5zOLcH59JyGKi rgCDDjpCYalvLwhIbmVYI2Hwyq4f5dchzZteb4IprXAj1Srll6DuahOJQMhVbBIepk0Y B39ivRZ5ga99og5Ic51HlbJFwPM4ZTtlRHothnLygoaxDPRH2kHUOy4jKINeclKPC9VY TPznQh+AgGdgvtlP/gxM8Qbzry/9QgYiw4l17Rq+ippl5gv/B+E3KOKZvmdKZOQIkE8J fjn5lv1BhjydCRMRiQBbkEZ9LyJq1q9t16xWhi0YK2xWpgymGUNa/6jXd7D3RYWQQIwZ NmZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=C85LOMde; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id la26-20020a170907781a00b009333804035fsi762089ejc.502.2023.03.22.10.52.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 10:52:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=C85LOMde; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 21DAC383E6B1 for ; Wed, 22 Mar 2023 17:50:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21DAC383E6B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679507446; bh=CCVuVAa5yGs1kEKzZOsj/u/crx5jQDUC9l1s1UyAwxs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=C85LOMdewJN2Hpb7ZGrJYIXlmr9bpBcloJEc9ufxqQJWR6DecmnmLlUihfJenUNgl 3qzJlTfT72FLGCAJwL8Xu81psXbQjBPOp5UMgemSR/GFMw/gn3LQv40md1B/tys7ai OXrs8U6d7hkJUMDuSGFWPXDJAODcAZxAjZDX4dHQ= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 9BF09385B524 for ; Wed, 22 Mar 2023 17:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BF09385B524 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-558-LAajULCnNIq8b0Mhig4L0Q-1; Wed, 22 Mar 2023 13:49:48 -0400 X-MC-Unique: LAajULCnNIq8b0Mhig4L0Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3D5E185A78F; Wed, 22 Mar 2023 17:49:47 +0000 (UTC) Received: from localhost (unknown [10.33.36.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD556492C13; Wed, 22 Mar 2023 17:49:47 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add allocator-extended constructors to std::match_results (LWG 2195) Date: Wed, 22 Mar 2023 17:49:47 +0000 Message-Id: <20230322174947.407957-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: 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?1761091279626478266?= X-GMAIL-MSGID: =?utf-8?q?1761091279626478266?= Tested powerpc64le-linux, pushed to trunk. -- >8-- This was approved in Issaquah last month. libstdc++-v3/ChangeLog: * include/bits/regex.h (match_results): Add allocator-extended copy and move constructors, as per LWG 2195. * testsuite/28_regex/match_results/ctors/char/alloc.cc: New test. --- libstdc++-v3/include/bits/regex.h | 10 ++++ .../match_results/ctors/char/alloc.cc | 56 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 386f4be9f4a..79903fad1e5 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -1826,6 +1826,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ ~match_results() = default; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2195. Missing constructors for match_results + + match_results(const match_results& __m, const _Alloc& __a) + : _Base_type(__m, __a) { } + + match_results(match_results&& __m, const _Alloc& __a) + noexcept(noexcept(_Base_type(std::move(__m), __a))) + : _Base_type(std::move(__m), __a) { } + ///@} // 28.10.2, state: diff --git a/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc new file mode 100644 index 00000000000..bb5e7a91bd7 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc @@ -0,0 +1,56 @@ +// { dg-do run { target c++11 } } + +#include +#include +#include + +// LWG 2195. Missing constructors for match_results + +void +test01() +{ + using Alloc = std::cmatch::allocator_type; + std::cmatch m1; + std::cmatch m2(m1, m1.get_allocator()); + VERIFY( m2 == m1 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended copy ctor is potentially-throwing" ); + + std::cmatch m3(std::move(m1), m2.get_allocator()); + VERIFY( m3 == m2 ); + + // Libstdc++ extension: + static_assert( std::is_nothrow_constructible(), + "Allocator-extended move ctor is non-throwing" ); +} + +void +test02() +{ + using Alloc = __gnu_test::uneq_allocator; + using MR = std::match_results; + + MR m1(Alloc(1)); + MR m2(m1, Alloc(2)); + VERIFY( m2 == m1 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended copy ctor is potentially-throwing" ); + + MR m3(std::move(m1), Alloc(3)); + VERIFY( m3 == m2 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended move ctor is potentially-throwing" ); +} + +int main() +{ + test01(); + test02(); +}