Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2225368/?format=api
{ "id": 2225368, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2225368/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260420215359.1773044-1-jason@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api", "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": "<20260420215359.1773044-1-jason@redhat.com>", "date": "2026-04-20T21:52:04", "name": "[RFC] c++: constexpr union with no active member [PR124910]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e6b23c85966391db973d1dc361e80f342c60185b", "submitter": { "id": 4337, "url": "http://patchwork.ozlabs.org/api/1.1/people/4337/?format=api", "name": "Jason Merrill", "email": "jason@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260420215359.1773044-1-jason@redhat.com/mbox/", "series": [ { "id": 500690, "url": "http://patchwork.ozlabs.org/api/1.1/series/500690/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500690", "date": "2026-04-20T21:52:04", "name": "[RFC] c++: constexpr union with no active member [PR124910]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500690/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2225368/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225368/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=gjGQ7WRP;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=gjGQ7WRP", "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 [38.145.34.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 4fzzn647CVz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 07:55:21 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4486E4CCCA07\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 21:55:19 +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 59A934D108C0\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 21:54:12 +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-549-5gtmfxXuNH2o6lcD2YBeJQ-1; Mon,\n 20 Apr 2026 17:54:01 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\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 C74B4195608B\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 21:54:00 +0000 (UTC)", "from jason-thinkpadp1gen4i.rmtusma.csb (unknown [10.22.65.102])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 4F55A1800446; Mon, 20 Apr 2026 21:54:00 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 4486E4CCCA07", "OpenDKIM Filter v2.11.0 sourceware.org 59A934D108C0" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 59A934D108C0", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 59A934D108C0", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776722052; cv=none;\n b=DuVG73RqoTH+GOhCKt5S+/RRucLZTnRjqILXgzlSn5rmHU55ORPLuGBMXtLGEEvIC54++8gGRcYl6zM3xPyGsBR7c0pBXrs3g80+gVjkB91uHMrtlCoLYMPglIvPftlUKKZG8ASf1JwGzTPXNjnH74UQEzu6sTtKJPRiQdoEsC4=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776722052; c=relaxed/simple;\n bh=Se1iUeY2xMNU/EzncSNqzZVIvFzVN+3X/yjU5/fwYjQ=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=LSqGxSFpnf01lc0rXB3Y3UlL1Rs7Gn2/t63qx8N85m0EcrKBveSiPyGFVwjleIkBRXPMXYWwDBDSliFrdzihu3FK6/0/mMwDQJJ2jTz4FJzLvOxEBFkru0hbV7ea/2qAVvcsRrcugSuG69uR2U3qWnK5bEHIE3QF69353BIJHt4=", "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=1776722052;\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=686Fv40Soj6Irbifyp+DkSN7z0oXzAPI3fnUeIYZv20=;\n b=gjGQ7WRPyK0vX2UOc+syXMjfRVChw/3o1rHFCUPl7Qmz1V4oxxHNFp8SAXDWMeJRHzRoY+\n 1ABXGL0zkfWVjT/IdAeuEBrvk2vjnWfmAz0rb2QdAIzhmyg2b3bia6X8sEflrPtkpXo6rM\n 7kKQ01aiOgUDt/k6PeOdwO0/KWpZQtk=", "X-MC-Unique": "5gtmfxXuNH2o6lcD2YBeJQ-1", "X-Mimecast-MFC-AGG-ID": "5gtmfxXuNH2o6lcD2YBeJQ_1776722041", "From": "Jason Merrill <jason@redhat.com>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Patrick Palka <ppalka@redhat.com>", "Subject": "[PATCH RFC] c++: constexpr union with no active member [PR124910]", "Date": "Mon, 20 Apr 2026 17:52:04 -0400", "Message-ID": "<20260420215359.1773044-1-jason@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "ocLUKIegqketu1pcBvmvec2gDzTkEJWUQF50Z2GO7Eg_1776722041", "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 x86_64-pc-linux-gnu. Since this isn't a regression I'm inclined to\nleave it for 17.\n\n-- 8< --\n\nPatrick pointed out that while r16-8767 made a union constant after\ndestroying its active member, we still weren't treating a union that never\nhad an active member as constant; the difference is the\nCONSTRUCTOR_NO_CLEARING flag, and what that means to\nreduced_constant_expression_p.\n\nIt seems to me that since P2686 [expr.const] says whether a prvalue\nexpression is a constant expression depends on the constituent values, and\n[intro.object] says that only the active member is a constituent value of a\nunion, so a union with no active member has no constituent values and so is\nvacuously constant, like an object of empty type. P2686 as a whole is not a\nDR, but the draft was previously unclear, and CWG2658 also clarified that\ncopying a union is equivalent to copying the active member *if any*.\n\nI was somewhat surprised that none of the existing tests needed to be\nchanged.\n\n\tPR c++/124910\n\tDR 2658\n\ngcc/cp/ChangeLog:\n\n\t* constexpr.cc (reduced_constant_expression_p): Allow a union\n\twith no active member.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/cpp2a/constexpr-union12.C: New test.\n---\n gcc/cp/constexpr.cc | 7 ++++---\n gcc/testsuite/g++.dg/cpp2a/constexpr-union12.C | 8 ++++++++\n 2 files changed, 12 insertions(+), 3 deletions(-)\n create mode 100644 gcc/testsuite/g++.dg/cpp2a/constexpr-union12.C\n\n\nbase-commit: 8e6b7c97232489557e376bdc134ad69aaeb35794", "diff": "diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc\nindex a593b66dd41..1926b64cbb7 100644\n--- a/gcc/cp/constexpr.cc\n+++ b/gcc/cp/constexpr.cc\n@@ -4747,9 +4747,10 @@ reduced_constant_expression_p (tree t, tree sz /* = NULL_TREE */)\n \t\t && TREE_CODE (TREE_TYPE (t)) == UNION_TYPE)\n \t {\n \t if (CONSTRUCTOR_NELTS (t) == 0)\n-\t\t/* An initialized union has a constructor element. */\n-\t\treturn false;\n-\t /* And it only initializes one member. */\n+\t\t/* A union with no active member has no constituent values, so\n+\t\t all constituent values are constant. */\n+\t\tgoto ok;\n+\t /* A union can have at most one active member. */\n \t field = NULL_TREE;\n \t }\n \t else\ndiff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-union12.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-union12.C\nnew file mode 100644\nindex 00000000000..42ddfaaf775\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-union12.C\n@@ -0,0 +1,8 @@\n+// PR c++/124910\n+// { dg-do compile { target c++20 } }\n+\n+union U {\n+ int n;\n+ constexpr U() { }\n+};\n+constexpr U u; // { dg-bogus \"\" } U() is not a constant expression\n", "prefixes": [ "RFC" ] }