{"id":2225355,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2225355/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260420212533.3862595-1-ppalka@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/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},"msgid":"<20260420212533.3862595-1-ppalka@redhat.com>","date":"2026-04-20T21:25:33","name":"libstdc++: Restrict engaged -> disengaged std::optional fix [PR124910]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"9b569ca8aff01b9c7efb02f87de0a10648a0bda2","submitter":{"id":78319,"url":"http://patchwork.ozlabs.org/api/1.1/people/78319/?format=json","name":"Patrick Palka","email":"ppalka@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260420212533.3862595-1-ppalka@redhat.com/mbox/","series":[{"id":500686,"url":"http://patchwork.ozlabs.org/api/1.1/series/500686/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500686","date":"2026-04-20T21:25:33","name":"libstdc++: Restrict engaged -> disengaged std::optional fix [PR124910]","version":1,"mbox":"http://patchwork.ozlabs.org/series/500686/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225355/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225355/checks/","tags":{},"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\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Tn3InJn8;\n\tdkim-atps=neutral","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\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Tn3InJn8","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124"],"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 4fzz881wZrz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 07:26:26 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id BBB564C515FA\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 21:26:24 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 59BCA4BA2E16\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 21:25:38 +0000 (GMT)","from mail-qv1-f72.google.com (mail-qv1-f72.google.com\n [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-353-Q7Mbf9l0N3SXc87LVBwfkg-1; Mon, 20 Apr 2026 17:25:37 -0400","by mail-qv1-f72.google.com with SMTP id\n 6a1803df08f44-89f59c9bd28so4882596d6.1\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 14:25:36 -0700 (PDT)","from idea ([2600:4040:aa66:bf00:9e8e:99ff:fed1:71f])\n by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b02ac4260bsm83411966d6.4.2026.04.20.14.25.33\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 20 Apr 2026 14:25:34 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org BBB564C515FA","OpenDKIM Filter v2.11.0 sourceware.org 59BCA4BA2E16"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 59BCA4BA2E16","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 59BCA4BA2E16","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776720338; cv=none;\n b=UgtWrjU3hnLuALkJrlAi3wwkNJcmf9SvhLmUFHTaJkFtZNaZV8FG2ePhpTbwEsCgt5MhzxlDSEQcRTwl/tvurvFlrMgPtQi6vYx+7fVhnuwmNbL4GvHPc+SfsPRJC26qMs2RMxQQ3NW/bobWSXo17BRCSEfnWf7wJpFLsC4Z9vw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776720338; c=relaxed/simple;\n bh=COv5qTYKO0H5DmT9+CagFZ39TmO7if01YDThkVe8Fdo=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=cZz7kZBUGLZI+8guvPv3loFEVfTa9tPG7G9iKsGiDaTai6If29zV3NVXZ1bLAzTfJ7vaQn1p3dZQzL+hvOV0UbFc8u3OG4cm8bcl6+ncqzTgjFS33l0kcHCoEELIMvDcKRwRjmcF+6YqmCTIVuVSNBQzGV83V8VN0jyBQwN7NMs=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776720338;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=OiQatfn1g33STko/xlYIU6Fdlbghz5d7q4eyGBNa8f4=;\n b=Tn3InJn8ZlJmXgdXi1MkYnNQZ7jibzVyzD9pMfWH/hhR2kmCUPV0/B478MpHLS17AOzpTk\n VBgaZQjvyWobb/kQ3BqgD7v3CaQ7+26q/D6t/YM0NK0MwSFvMXQgJg8kJHdPngV6li8B/Q\n JGaeUnQTUkW407mkwMM5mpJ4M7iq+F8=","X-MC-Unique":"Q7Mbf9l0N3SXc87LVBwfkg-1","X-Mimecast-MFC-AGG-ID":"Q7Mbf9l0N3SXc87LVBwfkg_1776720336","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776720335; x=1777325135;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=OiQatfn1g33STko/xlYIU6Fdlbghz5d7q4eyGBNa8f4=;\n b=FQKAQPZFOfq2T7U8OxMmINsH2dTg5syYWJSVbQJfTBo4JFWFx7v/Hen5RAZpMohhub\n tnBTdCuRuO0C06ZsAlQg2mByiKis3t9N/IMIh+w3D1tT8ruKpLHv3saFXpvIUDy2zdmx\n QgPHz7I+bOeG16tB6d40kW/LOO+iDKMN5aCUdHEw4NILGoGtec+fKm37K/Z5zU6pz/eY\n 287m4vDMPFQX2YG4Mn96VgvWitNaTHeICA/AZXxySX07TG4C9f35k6Eh4OXxghSczqK/\n T4MeeJIz2aJkgF7kVLJyX8+JZr1f+GiXVcUI6nUQNw9nblg+FpXUKWendMDiWvvPF7SA\n Wrtg==","X-Gm-Message-State":"AOJu0YwZWa36gh9nD0aj6A+LlC0KfjrBMOqQnuUe5ERVNwo2xmixo1Jx\n zCnSoUAzLXU/6iWujJp8vsknAJZ+ILMVQRoScjlAdBfZAMMz/4Nc9ailReLJdynSCJ+2gmWFinh\n iKCXsgSntfhlVQnmz9OBX2h6B+l7+v1n1pml3mkz70WDDMYo7qxBjwpTOAVN7JZSYvScoKg3JXC\n PQydp/n67/bXoAn3Ph7zSHSXoCMsM6efkgjfZWRR+t","X-Gm-Gg":"AeBDieu8ssHiAH2mit7HtdvUwqzzDGD3Zq936aIV2t6cXFWPD2goea5ghcDrUWenFAQ\n 0D2EHOaTFAaSsDx9bfaX7WlXH0CoVr9LTw/mLsap+qP8wlkfn49Ep9kYJI7iH01ioVCAlslZgRZ\n AsXNKw4fSIU+zQuCB7+IFXt2Pvl7iGfbqS6uBqvN8B+upnkFqYySXdwtmWwq2RqFPUIULMvktYa\n cXh3WWyFSRjP0u8REGoggST71LyrG3rksiqrUGpwrg4y0gnfuV2YETwj3EGWvClvZ7/HECQS3cl\n snCShhxQ/KS6kgNAaUPeJJakSg/d2nqc0qPy95VUwWeAX4LtAsXnJEb6E9HVLPF3t5jf2iHMzA8\n 7mqg41u0UA2jKZ5nJfuxvYtQ=","X-Received":["by 2002:ad4:4eef:0:b0:89c:c7ee:fe96 with SMTP id\n 6a1803df08f44-8b028191923mr180849406d6.8.1776720335363;\n Mon, 20 Apr 2026 14:25:35 -0700 (PDT)","by 2002:ad4:4eef:0:b0:89c:c7ee:fe96 with SMTP id\n 6a1803df08f44-8b028191923mr180849046d6.8.1776720334854;\n Mon, 20 Apr 2026 14:25:34 -0700 (PDT)"],"From":"Patrick Palka <ppalka@redhat.com>","To":"gcc-patches@gcc.gnu.org","Cc":"libstdc++@gcc.gnu.org,\n\tPatrick Palka <ppalka@redhat.com>","Subject":"[PATCH] libstdc++: Restrict engaged -> disengaged std::optional fix\n [PR124910]","Date":"Mon, 20 Apr 2026 17:25:33 -0400","Message-ID":"<20260420212533.3862595-1-ppalka@redhat.com>","X-Mailer":"git-send-email 2.54.0.rc1.54.g60f07c4f5c","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"XPSM9WADQNUXcIMQvWHJJvZvH-Y46Zb-C9TvRk5ol8I_1776720336","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; 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":"Tested on x86_64-pc-linux-gnu, does this look OK for trunk?\n\n-- >8 --\n\nIt turns out a union without an active member does not violate C++20 core\nconstant expression rules and r16-8748 was really just a workaround for\na front end bug.  The actual underlying problem -- that the constexpr\nevaluator treated an explicitly destroyed union member as still active\n-- has been fixed by r16-8767 which makes this workaround unnecessary\nfor GCC.  Rather than remove the workaround, restrict it to Clang which\nseems to have a similar bug.\n\n\tPR c++/124910\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/std/optional (_Optional_payload_base::_M_destroy):\n\tRestrict r16-8748 workaround to Clang, and adjust comment.\n---\n libstdc++-v3/include/std/optional | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)","diff":"diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional\nindex 49ba7b6b45dd..b9cc019feff7 100644\n--- a/libstdc++-v3/include/std/optional\n+++ b/libstdc++-v3/include/std/optional\n@@ -321,10 +321,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       {\n \t_M_engaged = false;\n \t_M_payload._M_value.~_Stored_type();\n-#if __cpp_lib_optional >= 202106L // full constexpr support\n+#if defined(__clang__) && __cpp_lib_optional >= 202106L // full constexpr support\n \tif (std::is_constant_evaluated())\n-\t  // Ensure union _M_payload always has an active member, for sake\n-\t  // of the core constant expression requirements.\n+\t  // Work around PR124910 for Clang.\n \t  std::construct_at(std::__addressof(_M_payload._M_empty));\n #endif\n       }\n","prefixes":[]}