{"id":2222811,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222811/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260413190449.109479-1-ncm@cantrip.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260413190449.109479-1-ncm@cantrip.org>","list_archive_url":null,"date":"2026-04-13T19:00:18","name":"libstdc++: Small allocator fixes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c2ac91cbc6b9dfa37819b16d666753182da646cb","submitter":{"id":90892,"url":"http://patchwork.ozlabs.org/api/1.2/people/90892/?format=json","name":"Nathan Myers","email":"ncm@cantrip.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260413190449.109479-1-ncm@cantrip.org/mbox/","series":[{"id":499740,"url":"http://patchwork.ozlabs.org/api/1.2/series/499740/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499740","date":"2026-04-13T19:00:18","name":"libstdc++: Small allocator fixes","version":1,"mbox":"http://patchwork.ozlabs.org/series/499740/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222811/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222811/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=none (p=none dis=none) header.from=cantrip.org","sourceware.org; spf=fail smtp.mailfrom=cantrip.org","server2.sourceware.org;\n arc=none smtp.remote-ip=207.211.30.44"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvcLH4ZPPz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 05:05:26 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 5ACCE4BA2E16\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 19:05:24 +0000 (GMT)","from us-smtp-delivery-44.mimecast.com\n (us-smtp-delivery-44.mimecast.com [207.211.30.44])\n by sourceware.org (Postfix) with ESMTP id C071D4BA2E07\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 19:04:57 +0000 (GMT)","from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-OfstzLKcPTGyBmjccQOq8g-1; Mon,\n 13 Apr 2026 15:04:52 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 0129E19560BF; Mon, 13 Apr 2026 19:04:52 +0000 (UTC)","from redhat.redhat.com (unknown [10.22.89.129])\n by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 637231955D88; Mon, 13 Apr 2026 19:04:50 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 5ACCE4BA2E16","OpenDKIM Filter v2.11.0 sourceware.org C071D4BA2E07"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org C071D4BA2E07","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org C071D4BA2E07","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776107097; cv=none;\n b=iMfZRrcCy7kOGIRrD+WA0yoBPK8wm6mnq45SYEcEoc3HArsGigY2KzILUaOEsv6bf13tgXbXAiVaJrSmM6QNxiNfCeKwTc8s93FHkZjdLd3e+q667YmCufjrSNnxQu2DF6io5by5PiNUKEDDnaT3A9WUwP8txOgt3dkCHMVSjCs=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776107097; c=relaxed/simple;\n bh=Y1T+V0BMaK6NK2Z/d4vvYWJ+c4SSPA0otL+bDxjOVTI=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=VOrcRJuiDm5L+GHuXlNv3y2AYvkZenUbRV4X40V303EwNia+VAGKGrrzwtjcFGy2STB4+PLrqJddTW5O6OEdcfS5O3/xQdjihUnlgtQe/u17WkmsvTcT7F6l3q0XA6ubYxLR0TFFJTH+azk6gwVI+rpx7nfkC0OWxQJ1q89ilZ8=","ARC-Authentication-Results":"i=1; server2.sourceware.org","X-MC-Unique":"OfstzLKcPTGyBmjccQOq8g-1","X-Mimecast-MFC-AGG-ID":"OfstzLKcPTGyBmjccQOq8g_1776107092","From":"Nathan Myers <ncm@cantrip.org>","To":"gcc-patches@gcc.gnu.org,\n\tlibstdc++@gcc.gnu.org","Subject":"[PATCH] libstdc++: Small allocator fixes","Date":"Mon, 13 Apr 2026 15:00:18 -0400","Message-ID":"<20260413190449.109479-1-ncm@cantrip.org>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"DsPe3yjVKcC-ql-pON9jVfNvpOhIJhlDf11YPeGQQb8_1776107092","X-Mimecast-Originator":"cantrip.org","Content-Transfer-Encoding":"quoted-printable","content-type":"text/plain; charset=WINDOWS-1252; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Since 2022, the constexpr branch of std::allocator::allocate(n)\nhas asked for the wrong size. More recently, allocator_traits\nallocate_at_least has taken its allocator argument by value,\nincorrectly.\n\nlibstdc++-v3/ChangeLog:\n\t* include/bits/allocator.h (allocate): When constexpr, allocate bytes.\n\t* include/bits/alloc_traits.h (allocate_at_least): Take allocator\n\targument by reference, per spec.\n---\n libstdc++-v3/include/bits/alloc_traits.h | 2 +-\n libstdc++-v3/include/bits/allocator.h    | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)","diff":"diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h\nindex 2be8ed561d4..e4e0f1608de 100644\n--- a/libstdc++-v3/include/bits/alloc_traits.h\n+++ b/libstdc++-v3/include/bits/alloc_traits.h\n@@ -670,7 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n        *  Returns `a.allocate_at_least(n)`.\n       */\n       [[nodiscard]] static constexpr auto\n-      allocate_at_least(allocator_type __a, size_type __n)\n+      allocate_at_least(allocator_type& __a, size_type __n)\n \t-> allocation_result<pointer, size_type>\n       { return __a.allocate_at_least(__n); }\n #endif\ndiff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h\nindex 9c22c805ebe..ae735605f67 100644\n--- a/libstdc++-v3/include/bits/allocator.h\n+++ b/libstdc++-v3/include/bits/allocator.h\n@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t  {\n \t    if (__builtin_mul_overflow(__n, sizeof(_Tp), &__n))\n \t      std::__throw_bad_array_new_length();\n-\t    return static_cast<_Tp*>(::operator new(__n));\n+\t    return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));\n \t  }\n \n \treturn __allocator_base<_Tp>::allocate(__n, 0);\n","prefixes":[]}