From patchwork Wed Jul 10 21:06:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1959017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AzANQ2q/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WK9S53xt8z1xqr for ; Thu, 11 Jul 2024 07:08:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBB8F38708FD for ; Wed, 10 Jul 2024 21:08:03 +0000 (GMT) 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 9906538708F2 for ; Wed, 10 Jul 2024 21:07:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9906538708F2 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9906538708F2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720645664; cv=none; b=iR91+ACAqDTeJ034Oerjk+EQwlI5Gt2uxU2evFShJomvEvRE0SrR7RjDCQVTheeQMK9Y+vZA9fJTj7a8DROfK1PVFhru8AiONBngOJ5k60tp7DSuv/eVP67fMyCZ3u2xvl59eAcQ9RXabgbxrmufrpdLXCJ/cLrdAHnrk+TZFV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720645664; c=relaxed/simple; bh=3EJxnzyJZaapM6X0We0sdqMQkUiqutD4dxVjzQO03Nw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=s//+nAmWNXS/yWDq6IvNjtlH9vKHQh7ZrxRuzz05HM//DJmJtym/hVLBC6GAuDnG69jDiO1saiGSC4UsBgLiDWGwOsO3pT5G3M+YXh1+rlbMoOwPlb0ZHWS41Nvhk/hS3Dl97fzXOXLjLx4UiAGT2XK2Zh2qdGEOtjm75P1NTmI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720645662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TF3S0JezruJ5tD9e/7GfFi1mRiPVH8PZiHHa3LciKqo=; b=AzANQ2q/jGmIQdxYpJwfxw3G5LTc8eIM9YAX3av2Y6E7twkMhz8+W2/4Y5lbrwrHEbH9mr QfTsKpeVwDZtUWk/aBTC35EgxMdkaKi2BY9uHwHMOsJgtwn/rz9jnkrG/0jRkEoFdk7s5z PJCZD+xBxEZ042l2Ry+mqpxfTArYcdU= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-8PqsoX21Ot-1NLnC8jSCpg-1; Wed, 10 Jul 2024 17:07:40 -0400 X-MC-Unique: 8PqsoX21Ot-1NLnC8jSCpg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C063B19560B6; Wed, 10 Jul 2024 21:07:38 +0000 (UTC) Received: from localhost (unknown [10.42.28.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C9DA519560AA; Wed, 10 Jul 2024 21:07:36 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use direct-initialization for std::vector's allocator [PR115854] Date: Wed, 10 Jul 2024 22:06:53 +0100 Message-ID: <20240710210735.906812-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, URI_HEX 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux. Pushed to trunk. Backports could follow. -- >8 -- The consensus in the standard committee is that this change shouldn't be necessary, and the Allocator requirements should require conversions between rebound allocators to be implicit. But we can make it work for now anyway. libstdc++-v3/ChangeLog: PR libstdc++/115854 * include/bits/stl_bvector.h (_Bvector_base): Convert allocator to rebound type explicitly. * testsuite/23_containers/vector/allocator/115854.cc: New test. * testsuite/23_containers/vector/bool/allocator/115854.cc: New test. --- libstdc++-v3/include/bits/stl_bvector.h | 2 +- .../testsuite/23_containers/vector/allocator/115854.cc | 10 ++++++++++ .../23_containers/vector/bool/allocator/115854.cc | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 8685cc64cc4..245e1c3b3a7 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -654,7 +654,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Bvector_base(const allocator_type& __a) - : _M_impl(__a) { } + : _M_impl(_Bit_alloc_type(__a)) { } #if __cplusplus >= 201103L _Bvector_base(_Bvector_base&&) = default; diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc new file mode 100644 index 00000000000..6c9016b311f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/115854.cc @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } + +#include +#include + +__gnu_test::ExplicitConsAlloc alloc; +std::vector> v; +std::vector> v1(alloc); +std::vector> v2(v1, alloc); +std::vector> v3(std::move(v1), alloc); diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc new file mode 100644 index 00000000000..14b28cc3e96 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/115854.cc @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } + +#include +#include + +__gnu_test::ExplicitConsAlloc alloc; +std::vector> v; +std::vector> v1(alloc); +std::vector> v2(v1, alloc); +std::vector> v3(std::move(v1), alloc);