[{"id":3673801,"web_url":"http://patchwork.ozlabs.org/comment/3673801/","msgid":"<d4b4d073-bca2-455f-9028-548aeec0b506@redhat.com>","list_archive_url":null,"date":"2026-04-06T16:41:49","subject":"Re: [PATCH] c++/modules: Fix propagating noexcept for templates\n [PR124785]","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/5/26 10:56 AM, Nathaniel Shead wrote:\n> Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk/15?\n\nOK.\n\n> -- >8 --\n> \n> We triggered a checking assertion because when propagating deduced\n> noexcept, we were updating the type of the existing TEMPLATE_DECL but\n> not the type of its DECL_TEMPLATE_RESULT, violating assumptions made\n> later on during modules streaming.\n> \n> But actually there was nothing to propagate here anyway, these\n> declarations are identical, so this patch also fixes the condition for\n> checking whether we need to propagate anything.  And so now I don't\n> think there is ever a case we should have a noexcept-spec to propagate\n> for a TEMPLATE_DECL, so add an assertion to validate this.\n> \n> \tPR c++/124785\n> \n> gcc/cp/ChangeLog:\n> \n> \t* module.cc (trees_in::is_matching_decl): Narrow condition for\n> \twhen noexcept propagation occurs; assert that we don't propagate\n> \tnoexcept-specs for TEMPLATE_DECLs.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* g++.dg/modules/noexcept-5.h: New test.\n> \t* g++.dg/modules/noexcept-5_a.C: New test.\n> \t* g++.dg/modules/noexcept-5_b.C: New test.\n> \t* g++.dg/modules/noexcept-5_c.C: New test.\n> \n> Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>\n> ---\n>   gcc/cp/module.cc                            |  4 +++-\n>   gcc/testsuite/g++.dg/modules/noexcept-5.h   |  4 ++++\n>   gcc/testsuite/g++.dg/modules/noexcept-5_a.C |  7 +++++++\n>   gcc/testsuite/g++.dg/modules/noexcept-5_b.C |  7 +++++++\n>   gcc/testsuite/g++.dg/modules/noexcept-5_c.C | 11 +++++++++++\n>   5 files changed, 32 insertions(+), 1 deletion(-)\n>   create mode 100644 gcc/testsuite/g++.dg/modules/noexcept-5.h\n>   create mode 100644 gcc/testsuite/g++.dg/modules/noexcept-5_a.C\n>   create mode 100644 gcc/testsuite/g++.dg/modules/noexcept-5_b.C\n>   create mode 100644 gcc/testsuite/g++.dg/modules/noexcept-5_c.C\n> \n> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc\n> index a8517569a1b..8b820f97fee 100644\n> --- a/gcc/cp/module.cc\n> +++ b/gcc/cp/module.cc\n> @@ -12619,12 +12619,14 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)\n>         tree d_spec = TYPE_RAISES_EXCEPTIONS (d_type);\n>         if (DECL_MAYBE_DELETED (e_inner) || DEFERRED_NOEXCEPT_SPEC_P (e_spec))\n>   \t{\n> -\t  if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)\n> +\t  if (!(DECL_MAYBE_DELETED (d_inner)\n> +\t\t|| DEFERRED_NOEXCEPT_SPEC_P (d_spec))\n>   \t      || (UNEVALUATED_NOEXCEPT_SPEC_P (e_spec)\n>   \t\t  && !UNEVALUATED_NOEXCEPT_SPEC_P (d_spec)))\n>   \t    {\n>   \t      dump (dumper::MERGE)\n>   \t\t&& dump (\"Propagating instantiated noexcept to %N\", existing);\n> +\t      gcc_checking_assert (existing == e_inner);\n>   \t      TREE_TYPE (existing) = d_type;\n>   \n>   \t      /* Propagate to existing clones.  */\n> diff --git a/gcc/testsuite/g++.dg/modules/noexcept-5.h b/gcc/testsuite/g++.dg/modules/noexcept-5.h\n> new file mode 100644\n> index 00000000000..78d91322a1a\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/noexcept-5.h\n> @@ -0,0 +1,4 @@\n> +// PR c++/124785\n> +template <typename T> struct Iterator {\n> +  constexpr friend auto operator<=>(const Iterator&, const Iterator&) = default;\n> +};\n> diff --git a/gcc/testsuite/g++.dg/modules/noexcept-5_a.C b/gcc/testsuite/g++.dg/modules/noexcept-5_a.C\n> new file mode 100644\n> index 00000000000..72085717e60\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/noexcept-5_a.C\n> @@ -0,0 +1,7 @@\n> +// PR c++/124785\n> +// { dg-do compile { target c++20 } }\n> +// { dg-additional-options \"-fmodules\" }\n> +// { dg-module-cmi M:A }\n> +\n> +export module M:A;\n> +#include \"noexcept-5.h\"\n> diff --git a/gcc/testsuite/g++.dg/modules/noexcept-5_b.C b/gcc/testsuite/g++.dg/modules/noexcept-5_b.C\n> new file mode 100644\n> index 00000000000..928980b6c1d\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/noexcept-5_b.C\n> @@ -0,0 +1,7 @@\n> +// PR c++/124785\n> +// { dg-do compile { target c++20 } }\n> +// { dg-additional-options \"-fmodules\" }\n> +// { dg-module-cmi M:B }\n> +\n> +export module M:B;\n> +#include \"noexcept-5.h\"\n> diff --git a/gcc/testsuite/g++.dg/modules/noexcept-5_c.C b/gcc/testsuite/g++.dg/modules/noexcept-5_c.C\n> new file mode 100644\n> index 00000000000..d9349147766\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/noexcept-5_c.C\n> @@ -0,0 +1,11 @@\n> +// PR c++/124785\n> +// { dg-do compile { target c++20 } }\n> +// { dg-additional-options \"-fmodules -fdump-lang-module-alias\" }\n> +// { dg-module-cmi M }\n> +\n> +export module M;\n> +export import :A;\n> +export import :B;\n> +\n> +// The noexcept-specifiers are equivalent, no need to merge.\n> +// { dg-final { scan-lang-dump-not {Propagating instantiated noexcept} module } }","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=ZRgzkSB2;\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=ZRgzkSB2","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 4fqFVW572kz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 07 Apr 2026 02:42:27 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D2AB04BA2E3D\n\tfor <incoming@patchwork.ozlabs.org>; Mon,  6 Apr 2026 16:42:25 +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 00A004BA2E0E\n for <gcc-patches@gcc.gnu.org>; Mon,  6 Apr 2026 16:41:55 +0000 (GMT)","from mail-qk1-f198.google.com (mail-qk1-f198.google.com\n [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-611-ZSJZZB4wOCiHBcTCe_x-Kg-1; Mon, 06 Apr 2026 12:41:53 -0400","by mail-qk1-f198.google.com with SMTP id\n af79cd13be357-8d654ade33aso385683585a.1\n for <gcc-patches@gcc.gnu.org>; Mon, 06 Apr 2026 09:41:53 -0700 (PDT)","from [192.168.50.130]\n (130-44-146-247.s12789.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com.\n [130.44.146.247]) by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8d2a806ce52sm1282088985a.27.2026.04.06.09.41.49\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Mon, 06 Apr 2026 09:41:50 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D2AB04BA2E3D","OpenDKIM Filter v2.11.0 sourceware.org 00A004BA2E0E"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 00A004BA2E0E","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 00A004BA2E0E","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775493716; cv=none;\n b=pIiWdBEOXiO7k/ByPhiR7AMbo8y3yHGfDtYXlvQx2X9EFGH7wwBAnTopdLICtFFwFMjkspIClOOwzR0OrHLqsQ4HSiO67Te2fC2gNG5KMBTNPvutgUIDpD3kmTHpiz0cGLhOd0kNqq8pasM9D0P8ZnF+f4cNvmTa449ApGY6420=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775493716; c=relaxed/simple;\n bh=I0UHluB47iAcbqt5rQ7jErRptBggIdNyHZHEoUbvePo=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=XcTIC+z87nzLvD3zl1aN27cOX9smpIk2eHU6twH1TTKOBtGE/upP89Ok92IswfpMSwXHKVhR1IyL9k0TFqxl8lId22bn6/tl4wu24YBJ8SxxvImDSCWa1Gztv27KIAvVXqZsKHkw8Kat55ordBxOJUxeJLqrlKjEriEhMJyaKqU=","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=1775493715;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=lr97fIqTjBoZ3FcsWJSU6/bSJhuNKDt7wzlzGFzzRY8=;\n b=ZRgzkSB2G56vrGHfjHJLgUqZJot1vBVuf6lJHFumSKBJ5+24mU3ITL+sL2VwMzq0zty0O0\n zx9/2KFQo4DDUb0b8xYlZAOIAXp9Ik4CZOe67LxFKbh4EhqOHVUbCItNis4X2WnOiCckNs\n 6nZJWmGpQq5jN1ykOffoAqqc0eBbtaE=","X-MC-Unique":"ZSJZZB4wOCiHBcTCe_x-Kg-1","X-Mimecast-MFC-AGG-ID":"ZSJZZB4wOCiHBcTCe_x-Kg_1775493713","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775493712; x=1776098512;\n h=content-transfer-encoding:in-reply-to:from:content-language\n :references:to:subject:user-agent:mime-version:date:message-id\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=lr97fIqTjBoZ3FcsWJSU6/bSJhuNKDt7wzlzGFzzRY8=;\n b=n4HXN0X44Wmm1dlRiCdyUkakE4wVXmCFrSnGfDT+Xl/UJsvDdNyDaI+XQDE0cnzb/c\n 5YAKbIhBevqqnAg85GAdNGMxMEmtcuuknMyDuGc4s6TUgLz1ATfHuiT6OILHm93k9vkb\n 8SpTX2jFwMxc2KHWXzIgohcCgbt758u77WnYOYQNOEiBMbslQ3pzbAd4hO9DQG/aD56N\n WBq5d3CyBXeE/VEnbLLpz2YUunyeKXTqmup115rgnaD3m7gKiXdv8T6CBb9FYkqyTyY1\n QEGFNL1B8RCj3oF3EyIISiXGrsCjulhd9bOLohKbra+3poUKpSmfo753f4h7MaN3PUtq\n r6ug==","X-Forwarded-Encrypted":"i=1;\n AJvYcCVcOG6nWoIYvoqAjafwc8exbpikpX95sxh0XUxgvTdfTixkY2fsK9+ywcXwjzqCNb+JXVzMbqe1/QzfRw==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YzSFlU+vfs2W1nsao36YOsqgJ1RYYXMUgXHCTLZooSaLimEWbGu\n HTNsfINDnF6PxPojPSHjhRUvI+wNX06odAdcaV/U94BC6tVYLU6jRkYwerjz8FpHzj5YOyIwZrC\n 0IZxZzFQAA2gFEUJcLIYp1JUlGuleVeFSe8nrsAeQ6fc5Srv9Jsoxj+EIDlp7jS6wZj0hsQ==","X-Gm-Gg":"AeBDievaPodJWulibSNnwCNM7RsxoNcIqPEcrIT+A6WGphlGxEk6hVcCEb0rqq4SCwP\n lEogjNuXXwQs3LPt5MPKDXfMIqB4MpzbMvdbUmBPUCqve0tSUdc31AYU+GGjqW1jVvkWOfwk0Bw\n kqvzCvjJvi0NxA4SmNDre2PwmwGnltXrIZ0gaJmi1H4Er4E+QLF9DEwTQqukPLPe8SzJuzGJqLn\n vgkOn0XbGvwkivxpbJfphzZUn8E8SxKhoKucsDVHQm34se3B/sFUit01dGIIjbhkTD7vAQlhaEo\n USAxJoj5CzyaZVfFLSZa8AftxGgIPifZybiAiaLZXczFUxKF6kXovf+Ct8BAP5MHCcyC9UnrYtX\n a9/7o4M3HIBF8aIXxGLIX1lPD6lepFXcLjfiYTPnfz/PzuxQiFbYM3CFzYGOYsKRr24XVDHuyoh\n 1M6k+hQv1jUbf/0NIzvuT9VZmX5S9ggqw=","X-Received":["by 2002:a05:620a:44c8:b0:8cf:c2bf:af55 with SMTP id\n af79cd13be357-8d30207db5cmr2153696885a.19.1775493712486;\n Mon, 06 Apr 2026 09:41:52 -0700 (PDT)","by 2002:a05:620a:44c8:b0:8cf:c2bf:af55 with SMTP id\n af79cd13be357-8d30207db5cmr2153692585a.19.1775493711930;\n Mon, 06 Apr 2026 09:41:51 -0700 (PDT)"],"Message-ID":"<d4b4d073-bca2-455f-9028-548aeec0b506@redhat.com>","Date":"Mon, 6 Apr 2026 12:41:49 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/modules: Fix propagating noexcept for templates\n [PR124785]","To":"Nathaniel Shead <nathanieloshead@gmail.com>, gcc-patches@gcc.gnu.org","References":"<adJ4AoQdUp8Znpyj@Thaum.localdomain>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<adJ4AoQdUp8Znpyj@Thaum.localdomain>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"x-awiY-mp5Ndl5gKdKJXtF2JJDaPAHxTqFtFlwLW5XY_1775493713","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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"}}]