Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2194434/?format=api
{ "id": 2194434, "url": "http://patchwork.ozlabs.org/api/patches/2194434/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260208231200.958725-1-ibuclaw@gdcproject.org/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260208231200.958725-1-ibuclaw@gdcproject.org>", "list_archive_url": null, "date": "2026-02-08T23:12:00", "name": "[committed] d: Fix error when passing assert(0) as argument [PR123995]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "06ab92ad9539c766bc80d405f62847b069395160", "submitter": { "id": 46728, "url": "http://patchwork.ozlabs.org/api/people/46728/?format=api", "name": "Iain Buclaw", "email": "ibuclaw@gdcproject.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260208231200.958725-1-ibuclaw@gdcproject.org/mbox/", "series": [ { "id": 491447, "url": "http://patchwork.ozlabs.org/api/series/491447/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=491447", "date": "2026-02-08T23:12:00", "name": "[committed] d: Fix error when passing assert(0) as argument [PR123995]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/491447/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2194434/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2194434/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\tdkim=pass (2048-bit key;\n unprotected) header.d=gdcproject.org header.i=@gdcproject.org\n header.a=rsa-sha256 header.s=MBO0001 header.b=jFt63Bh0;\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 (2048-bit key,\n unprotected) header.d=gdcproject.org header.i=@gdcproject.org\n header.a=rsa-sha256 header.s=MBO0001 header.b=jFt63Bh0", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=gdcproject.org", "sourceware.org; spf=pass smtp.mailfrom=gdcproject.org", "server2.sourceware.org;\n arc=none smtp.remote-ip=80.241.56.172", "outgoing_mbo_mout; dkim=none;\n spf=pass (outgoing_mbo_mout: domain of ibuclaw@gdcproject.org designates\n 2001:67c:2050:b231:465::2 as permitted sender)\n smtp.mailfrom=ibuclaw@gdcproject.org" ], "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 4f8Ns26rNlz1xvc\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 09 Feb 2026 10:12:38 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 880F9452C42C\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 8 Feb 2026 23:12:36 +0000 (GMT)", "from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172])\n by sourceware.org (Postfix) with ESMTPS id 969F54793AF1\n for <gcc-patches@gcc.gnu.org>; Sun, 8 Feb 2026 23:12:06 +0000 (GMT)", "from smtp2.mailbox.org (smtp2.mailbox.org\n [IPv6:2001:67c:2050:b231:465::2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4f8NrM4B2hz9tWZ;\n Mon, 9 Feb 2026 00:12:03 +0100 (CET)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 880F9452C42C", "OpenDKIM Filter v2.11.0 sourceware.org 969F54793AF1" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 969F54793AF1", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 969F54793AF1", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770592326; cv=none;\n b=ab1aeKtmKiQOruVpVIDAEOMeSARVtGYv8QRWVAjUIW5BNaHA9EmTQeH8PwvDEkuSnUdVUSb//wJ5N+pWP7vJGGWU4IdJKCRJAHj2h+72H/D9mIhPiZp2M1Srsi73duHJX5rxWjBF3UtpT8LJL4vUpJ34GHU87XTBNd4iVWpSd7s=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1770592326; c=relaxed/simple;\n bh=jrdpFlP4mj/mw0lr+2d0B6CjDrI9nOvNOYynQr5BAbQ=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=CWLeJc2MMaoTeODw6gc77JIKmBN9ff5J4e+8l1Razf60vzFAo6nyb/ufvxwtPNC9UxL44pFncd8/6+P/C0IXb+q7nmp2E7gqKUQyWzwoysHzlHlsuxudkaBm9T1rgjGfbFCY3Q1qdBosp6j4voEPS0Aok37nGFC+yZaKJ98MbFQ=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gdcproject.org;\n s=MBO0001; t=1770592323;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=4q7rHZEv4+h/ZD9gFhNy+AFh8PBkZzb6zKyzhmRKDCM=;\n b=jFt63Bh0UoQkB1nSN/JhEn+tJI6ZtXmuX2l7eC8dJ1NKAGg+6hbZw23JppfRB8C5qTXUy8\n a8B+/GqF/yw60qRv+XWvuxj7PCZZHuPlgSLdmAjSgvpktJux8RaY0BFv0bJBrVK8J2ND0R\n MyTUZJFAVcHf58V9C1s64gaLkXsUMNWDSaS995cz1vT3lq/Tfh6p8+XhICfKvwe6XWiVun\n 0Whv6hhENAOm9/3h4UpVqbXOZp/m81S0HyQmu7RLA9gcs2S9C79xCTrtCQTVnf22hzQCyH\n aOX96/pj3/28633Ppb5ieI7PDmQZhFhHBLyqIw12l8kM/VpmIRHnulcBf8b5wQ==", "From": "Iain Buclaw <ibuclaw@gdcproject.org>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Iain Buclaw <ibuclaw@gdcproject.org>", "Subject": "[committed] d: Fix error when passing assert(0) as argument\n [PR123995]", "Date": "Mon, 9 Feb 2026 00:12:00 +0100", "Message-ID": "<20260208231200.958725-1-ibuclaw@gdcproject.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Rspamd-Queue-Id": "4f8NrM4B2hz9tWZ", "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": "Hi,\n\nThis patch fixes PR123995.\n\nLibrary routines that either throw or halt execution already have the\ncall flag ECF_NORETURN. Make their internal type `noreturn' as well, so\nthat they can be \"passed\" to functions accepting noreturn arguments.\n\n\nRegstrapped on x86_64-linux-gnu, committed to mainline.\n\nRegards,\nIain.\n\n---\n\tPR d/123995\n\ngcc/d/ChangeLog:\n\n\t* d-codegen.cc (build_assert_call): Cast libcall result to `noreturn'.\n\t(build_array_bounds_call): Likewise.\n\t(build_bounds_index_condition): Likewise.\n\t(build_bounds_slice_condition): Likewise.\n\t* expr.cc (ExprVisitor::visit (ThrowExp *)): Likewise.\n\t* toir.cc (IRVisitor::visit (ThrowStatement *)): Likewise.\n\t* runtime.cc (enum d_libcall_type): Add LCT_NORETURN.\n\t(get_libcall_type): Handle LCT_NORETURN.\n\t* runtime.def (ASSERTP): Change return type to `noreturn'.\n\t(ASSERT_MSG): Likewise.\n\t(UNITTESTP): Likewise.\n\t(UNITTEST_MSG): Likewise.\n\t(ARRAYBOUNDSP): Likewise.\n\t(ARRAYBOUNDS_SLICEP): Likewise.\n\t(ARRAYBOUNDS_INDEXP): Likewise.\n\t(THROW): Likewise.\n\ngcc/testsuite/ChangeLog:\n\n\t* gdc.dg/pr123995.d: New test.\n---\n gcc/d/d-codegen.cc | 10 +++++-----\n gcc/d/expr.cc | 2 +-\n gcc/d/runtime.cc | 5 +++++\n gcc/d/runtime.def | 18 ++++++++++--------\n gcc/d/toir.cc | 2 +-\n gcc/testsuite/gdc.dg/pr123995.d | 16 ++++++++++++++++\n 6 files changed, 38 insertions(+), 15 deletions(-)\n create mode 100644 gcc/testsuite/gdc.dg/pr123995.d", "diff": "diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc\nindex 04fc63bda75..b22bdef77ce 100644\n--- a/gcc/d/d-codegen.cc\n+++ b/gcc/d/d-codegen.cc\n@@ -1994,9 +1994,9 @@ build_assert_call (const Loc &loc, libcall_fn libcall, tree msg)\n \n \n if (msg != NULL_TREE)\n- return build_libcall (libcall, Type::tvoid, 3, msg, file, line);\n+ return build_libcall (libcall, Type::tnoreturn, 3, msg, file, line);\n else\n- return build_libcall (libcall, Type::tvoid, 2, file, line);\n+ return build_libcall (libcall, Type::tnoreturn, 2, file, line);\n }\n \n /* Builds a CALL_EXPR at location LOC in the source file to execute when an\n@@ -2010,7 +2010,7 @@ build_array_bounds_call (const Loc &loc)\n return build_call_expr (builtin_decl_explicit (BUILT_IN_TRAP), 0);\n else\n {\n- return build_libcall (LIBCALL_ARRAYBOUNDSP, Type::tvoid, 2,\n+ return build_libcall (LIBCALL_ARRAYBOUNDSP, Type::tnoreturn, 2,\n \t\t\t build_filename_from_loc (loc),\n \t\t\t size_int (loc.linnum ()));\n }\n@@ -2039,7 +2039,7 @@ build_bounds_index_condition (IndexExp *ie, tree index, tree length)\n boundserr = build_call_expr (builtin_decl_explicit (BUILT_IN_TRAP), 0);\n else\n {\n- boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_INDEXP, Type::tvoid, 4,\n+ boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_INDEXP, Type::tnoreturn, 4,\n \t\t\t\t build_filename_from_loc (ie->e2->loc),\n \t\t\t\t size_int (ie->e2->loc.linnum ()),\n \t\t\t\t index, length);\n@@ -2089,7 +2089,7 @@ build_bounds_slice_condition (SliceExp *se, tree lower, tree upper, tree length)\n \t else\n \t {\n \t boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_SLICEP,\n-\t\t\t\t\t Type::tvoid, 5,\n+\t\t\t\t\t Type::tnoreturn, 5,\n \t\t\t\t\t build_filename_from_loc (se->loc),\n \t\t\t\t\t size_int (se->loc.linnum ()),\n \t\t\t\t\t lower, upper, length);\ndiff --git a/gcc/d/expr.cc b/gcc/d/expr.cc\nindex 6a5059bba89..d05a12d5d09 100644\n--- a/gcc/d/expr.cc\n+++ b/gcc/d/expr.cc\n@@ -1005,7 +1005,7 @@ public:\n void visit (ThrowExp *e) final override\n {\n tree arg = build_expr_dtor (e->e1);\n- this->result_ = build_libcall (LIBCALL_THROW, Type::tvoid, 1, arg);\n+ this->result_ = build_libcall (LIBCALL_THROW, Type::tnoreturn, 1, arg);\n }\n \n /* Build a postfix expression. */\ndiff --git a/gcc/d/runtime.cc b/gcc/d/runtime.cc\nindex fa291d8fd13..4fb63f85b5b 100644\n--- a/gcc/d/runtime.cc\n+++ b/gcc/d/runtime.cc\n@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see\n \n enum d_libcall_type\n {\n+ LCT_NORETURN,\t\t /* typeof(*null)\t */\n LCT_VOID,\t\t /* void\t\t */\n LCT_BYTE,\t\t /* byte\t\t */\n LCT_INT,\t\t /* int\t\t */\n@@ -89,6 +90,10 @@ get_libcall_type (d_libcall_type type)\n \n switch (type)\n {\n+ case LCT_NORETURN:\n+ libcall_types[type] = Type::tnoreturn;\n+ break;\n+\n case LCT_VOID:\n libcall_types[type] = Type::tvoid;\n break;\ndiff --git a/gcc/d/runtime.def b/gcc/d/runtime.def\nindex 9651c07dc8b..016f58756bf 100644\n--- a/gcc/d/runtime.def\n+++ b/gcc/d/runtime.def\n@@ -39,24 +39,26 @@ along with GCC; see the file COPYING3. If not see\n #define RT(T1)\tLCT_ ## T1\n \n /* Used when an assert() contract fails. */\n-DEF_D_RUNTIME (ASSERTP, \"_d_assertp\", RT(VOID), P2(IMMUTABLE_CHARPTR, UINT),\n+DEF_D_RUNTIME (ASSERTP, \"_d_assertp\", RT(NORETURN), P2(IMMUTABLE_CHARPTR, UINT),\n \t ECF_NORETURN)\n-DEF_D_RUNTIME (ASSERT_MSG, \"_d_assert_msg\", RT(VOID), P3(STRING, STRING, UINT),\n+DEF_D_RUNTIME (ASSERT_MSG, \"_d_assert_msg\", RT(NORETURN),\n+\t P3(STRING, STRING, UINT),\n \t ECF_NORETURN)\n \n /* Used when an assert() contract fails in a unittest function. */\n-DEF_D_RUNTIME (UNITTESTP, \"_d_unittestp\", RT(VOID), P2(IMMUTABLE_CHARPTR, UINT),\n+DEF_D_RUNTIME (UNITTESTP, \"_d_unittestp\", RT(NORETURN),\n+\t P2(IMMUTABLE_CHARPTR, UINT),\n \t ECF_NORETURN)\n-DEF_D_RUNTIME (UNITTEST_MSG, \"_d_unittest_msg\", RT(VOID),\n+DEF_D_RUNTIME (UNITTEST_MSG, \"_d_unittest_msg\", RT(NORETURN),\n \t P3(STRING, STRING, UINT), ECF_NORETURN)\n \n /* Used when an array index outside the bounds of its range. */\n-DEF_D_RUNTIME (ARRAYBOUNDSP, \"_d_arrayboundsp\", RT(VOID),\n+DEF_D_RUNTIME (ARRAYBOUNDSP, \"_d_arrayboundsp\", RT(NORETURN),\n \t P2(IMMUTABLE_CHARPTR, UINT), ECF_NORETURN)\n-DEF_D_RUNTIME (ARRAYBOUNDS_SLICEP, \"_d_arraybounds_slicep\", RT(VOID),\n+DEF_D_RUNTIME (ARRAYBOUNDS_SLICEP, \"_d_arraybounds_slicep\", RT(NORETURN),\n \t P5(IMMUTABLE_CHARPTR, UINT, SIZE_T, SIZE_T, SIZE_T),\n \t ECF_NORETURN)\n-DEF_D_RUNTIME (ARRAYBOUNDS_INDEXP, \"_d_arraybounds_indexp\", RT(VOID),\n+DEF_D_RUNTIME (ARRAYBOUNDS_INDEXP, \"_d_arraybounds_indexp\", RT(NORETURN),\n \t P4(IMMUTABLE_CHARPTR, UINT, SIZE_T, SIZE_T), ECF_NORETURN)\n \n /* Used when calling delete on a stack-allocated class or interface. */\n@@ -92,7 +94,7 @@ DEF_D_RUNTIME (ARRAYAPPENDWD, \"_d_arrayappendwd\", RT(ARRAY_VOID),\n \t P2(ARRAYPTR_BYTE, DCHAR), 0)\n \n /* Used for throw() expressions. */\n-DEF_D_RUNTIME (THROW, \"_d_throw\", RT(VOID), P1(OBJECT), ECF_NORETURN)\n+DEF_D_RUNTIME (THROW, \"_d_throw\", RT(NORETURN), P1(OBJECT), ECF_NORETURN)\n DEF_D_RUNTIME (BEGIN_CATCH, \"__gdc_begin_catch\", RT(VOIDPTR), P1(VOIDPTR), 0)\n \n /* C++ exception handlers. */\ndiff --git a/gcc/d/toir.cc b/gcc/d/toir.cc\nindex eb4e825ce1c..1ad41cf9368 100644\n--- a/gcc/d/toir.cc\n+++ b/gcc/d/toir.cc\n@@ -1241,7 +1241,7 @@ public:\n else\n arg = build_nop (build_ctype (get_object_type ()), arg);\n \n- add_stmt (build_libcall (LIBCALL_THROW, Type::tvoid, 1, arg));\n+ add_stmt (build_libcall (LIBCALL_THROW, Type::tnoreturn, 1, arg));\n }\n \n /* Build a try-catch statement, one of the building blocks for exception\ndiff --git a/gcc/testsuite/gdc.dg/pr123995.d b/gcc/testsuite/gdc.dg/pr123995.d\nnew file mode 100644\nindex 00000000000..c3e3b8327e0\n--- /dev/null\n+++ b/gcc/testsuite/gdc.dg/pr123995.d\n@@ -0,0 +1,16 @@\n+// { dg-do compile }\n+int fn123995(const typeof(*null) val)\n+{\n+ return 0;\n+}\n+\n+int pr123995a()\n+{\n+ return fn123995(assert(0));\n+}\n+\n+int pr123995b()\n+{\n+ static Exception ex;\n+ return fn123995(throw ex);\n+}\n", "prefixes": [ "committed" ] }