[{"id":3685160,"web_url":"http://patchwork.ozlabs.org/comment/3685160/","msgid":"<618df37e-6e03-40f8-b7d6-a1b326ad5e51@redhat.com>","list_archive_url":null,"date":"2026-05-01T15:47:47","subject":"Re: [PATCH] c++/modules: merging fndecl w/ inst noexcept + deduced\n auto [PR125115]","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/30/26 4:34 PM, Patrick Palka wrote:\n> Tested on x86_64-pc-linux-gnu, does this look OK for trunk/16?\n> \n> -- >8 --\n> \n> Here when streaming in view_interface<int>::data() and merging it with\n> the in-TU version, we find that the streamed-in version already has\n> its noexcept instantiated and its return type deduced.  is_matching_decl\n> has logic to update the in-TU version when that is the case, first by\n> propagating the instantiated noexcept and then the deduced return type.\n> But the noexcept propagation is done by overwriting the entire function\n> type with the streamed-in one, which simultaneously updates the return\n> type as well.  This premature return type updating breaks the later\n> deduced return type checks which are partially in terms of the original\n> function type.\n> \n> This patch fixes this by propagating the instantiated noexcept more\n> narrowly via build_exception_variant.  Also turn e_type and d_type into\n> references so that they're not stale after TREE_TYPE updating.\n> \n> \tPR c++/125115\n> \n> gcc/cp/ChangeLog:\n> \n> \t* module.cc (trees_in::is_matching_decl): Turn e_type and d_type\n> \tinto references.  Propagate instantiated noexcept via\n> \tbuild_exception_variant instead of using d_type.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* g++.dg/modules/auto-9_a.H: New test.\n> \t* g++.dg/modules/auto-9_b.C: New test.\n> \t* g++.dg/modules/auto-9_c.C: New test.\n> ---\n>   gcc/cp/module.cc                        |  7 ++--\n>   gcc/testsuite/g++.dg/modules/auto-9_a.H | 46 +++++++++++++++++++++++++\n>   gcc/testsuite/g++.dg/modules/auto-9_b.C | 11 ++++++\n>   gcc/testsuite/g++.dg/modules/auto-9_c.C | 10 ++++++\n>   4 files changed, 71 insertions(+), 3 deletions(-)\n>   create mode 100644 gcc/testsuite/g++.dg/modules/auto-9_a.H\n>   create mode 100644 gcc/testsuite/g++.dg/modules/auto-9_b.C\n>   create mode 100644 gcc/testsuite/g++.dg/modules/auto-9_c.C\n> \n> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc\n> index dc9981a5fc24..afd272209c83 100644\n> --- a/gcc/cp/module.cc\n> +++ b/gcc/cp/module.cc\n> @@ -12633,8 +12633,8 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)\n>   \t  goto mismatch;\n>   \t}\n>   \n> -      tree e_type = TREE_TYPE (e_inner);\n> -      tree d_type = TREE_TYPE (d_inner);\n> +      tree& e_type = TREE_TYPE (e_inner);\n> +      tree& d_type = TREE_TYPE (d_inner);\n>   \n>         for (tree e_args = TYPE_ARG_TYPES (e_type),\n>   \t     d_args = TYPE_ARG_TYPES (d_type);\n> @@ -12672,7 +12672,8 @@ trees_in::is_matching_decl (tree existing, tree decl, bool is_typedef)\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> +\t      TREE_TYPE (existing)\n> +\t\t= build_exception_variant (TREE_TYPE (existing), d_spec);\n\nHaving asserted that existing == e_inner, we could use e_type instead of \nTREE_TYPE (existing) here?\n\nOK either way.\n\nJason","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=cBbxKgk/;\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=cBbxKgk/","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.133.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 4g6b6Z5V9bz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 01:48:22 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DD99146A9CFF\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  1 May 2026 15:48:20 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 22C524BA23C5\n for <gcc-patches@gcc.gnu.org>; Fri,  1 May 2026 15:47:53 +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-654-ANRsUCkYMb2TZO7gjnoSNA-1; Fri, 01 May 2026 11:47:51 -0400","by mail-qv1-f72.google.com with SMTP id\n 6a1803df08f44-8a5f6110cadso52220056d6.3\n for <gcc-patches@gcc.gnu.org>; Fri, 01 May 2026 08:47:51 -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 6a1803df08f44-8b538c14514sm27035556d6.8.2026.05.01.08.47.48\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Fri, 01 May 2026 08:47:48 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org DD99146A9CFF","OpenDKIM Filter v2.11.0 sourceware.org 22C524BA23C5"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 22C524BA23C5","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 22C524BA23C5","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777650473; cv=none;\n b=wOX36Z7fRW+2nQPQh8VTDERJcAmXo3L4OW7vVt3WUf7/51pCw4bS6lLCeJ2LU+GDWJlHy4dacEKPj/LizqanemOIriJnghP8rMQyTjANkhqP1zixkJ0Mi9kxgAuoXfAD5Irpe4KKUuMhF1GVz6TTyBsrgWoUn0Fn1HwFLjwLRsY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777650473; c=relaxed/simple;\n bh=PX/L0pEycFgUYkzLt6MC5mc9mubLn/vsbhHDjTG/E+g=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=VGgijsdYGcmRTrRBY5xl0HXuDq1fTVpMquKs8RN3uTYo3Ih8+PbiGS86KvbUHhFmwwKGPAi2XIS9el62ujnnsctcbm1lVQuwm5BmYcwJDnXFaa24PPiilGyNnwaTSYsx8wLg6tDcvMAVKGWSwLPYm5+pUIEn/YgGeKAu0dqqHDQ=","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=1777650472;\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=oNo2WSlJCtnHokm8WHriBirR/X+tEtIlCEs7ErLONt8=;\n b=cBbxKgk/kIaWz5X/9MRl2jhfITp+nxaj6H2gKtQOPLCqtSXJuedWAIh5MknipUS++N4XdG\n Ka2ZczLBaxxCpkXZg7O+ot1KwVf4meWSz2ezupV9W7EyEpt9EikrHjj+wJr/zNplJMHwb1\n AqU7R+aw8H1b+UWth3ZWiwJJJhVnYCI=","X-MC-Unique":"ANRsUCkYMb2TZO7gjnoSNA-1","X-Mimecast-MFC-AGG-ID":"ANRsUCkYMb2TZO7gjnoSNA_1777650471","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777650470; x=1778255270;\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=oNo2WSlJCtnHokm8WHriBirR/X+tEtIlCEs7ErLONt8=;\n b=PYWbJRgFE1Yd0ll/6O4OpDbF7BKNTxA89/2ZImp6a/RnlI7ms9mcT1DCgn8ti2AVdq\n nQd6SRgkqKmvfPy/UyOjBle/1uGgu5eYAHaVk70w69/MOMEAG4RIHHvL5rt3kCm2KuSB\n 6h0hKLo2ZX9jyP2LsDXb+s7Jop5LTqMvrSP0bdRRmQblf6BFFf/Rp7JsS4n0VOK0hNx0\n vd0RMGorQaMwi213aS04ilXqjD9e/hwWbiFhY7XuboPNn/iHq/pkWVvzb9ydfXcSNpDr\n e1/nOYQ7RTl1j3qs9Befo4aObK9yLDbAA2biK/tnXCxlcLFdVUV0N8Nx9MS0ZtaaFVH/\n SfEA==","X-Forwarded-Encrypted":"i=1;\n AFNElJ/h1CR2+XdH4ba5Sk7WhDSkTIGx7GnUeSSJDNQLKjfz7CgZq28pxOuZoFk8WuiWvc0vUOmWmGNR3tHgyg==@gcc.gnu.org","X-Gm-Message-State":"AOJu0Yyuq3GLdfmudyI0SI49aRQXzfZ0kbtNP/OivPPl6c0nnUDZdfEW\n C8h24m7/3sVSHGixAmPJN67VcpH0xVoSMmHdbQfIgn+F/pnDwZthkufdBH2+iumvTduxM+/FFhn\n 32iu1/VUBBnu7oQ8Rm+7H8nm50MT1eOAUgOa9y8OdsSVBQxVeJnaZw9weL7kY1L8q7bE1/g==","X-Gm-Gg":"AeBDiet2kOQzX+uOQuAAtkbM29JC9dchqjpEYtPsmQ2SFa6LJwHJ9rZWcVC1ydaC/Yx\n NKWTJTvy88Ksfp1g7P82Rdq3zKlpwFLtZLOQ2bOEpoA1WGLW91F5UUGluOm5pkZgZuFlO/phHDO\n BC/KBYF14k4ydeIO2pd/eVt2t+JLn44b+N9f+DvGogIQfmQTJQDddpDFW6GAH8EK7Y3A00wB4w6\n T3pZVnG0S9Ir5HJB67FoYEQLCH4MbqbpmNq8638uCeHemMuIG17+FGmIO8lYADkIWjw8fpsgHP4\n YT9UVDLSr4kDhHG8OkJGKZJGIrQOhN3Zc6LOszv2JjVIULElQ2pSUltQ12S3Mna4XUTsG/Hr2CD\n 5mKyEL6tUJcdLdewwgwciwFMevkavj8yN83cVjJ34I3EeSfR3SRc1zKDuypX51Tu8Gph8kDGb4m\n vTCFZTme3/EaW+7pdl5sGUxHK8Cqs2MkSYA5Go5ttjZw==","X-Received":["by 2002:ad4:5ecc:0:b0:8ae:6587:3d54 with SMTP id\n 6a1803df08f44-8b667e6ed4bmr242966d6.26.1777650469760;\n Fri, 01 May 2026 08:47:49 -0700 (PDT)","by 2002:ad4:5ecc:0:b0:8ae:6587:3d54 with SMTP id\n 6a1803df08f44-8b667e6ed4bmr242336d6.26.1777650469247;\n Fri, 01 May 2026 08:47:49 -0700 (PDT)"],"Message-ID":"<618df37e-6e03-40f8-b7d6-a1b326ad5e51@redhat.com>","Date":"Fri, 1 May 2026 11:47:47 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/modules: merging fndecl w/ inst noexcept + deduced\n auto [PR125115]","To":"Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org","References":"<20260430203447.3995696-1-ppalka@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<20260430203447.3995696-1-ppalka@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"TWMn84_rSS8EjnWDvzKLcEBItBdQEzfPSUiOrdQ1Pzw_1777650471","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"}}]