[{"id":3684891,"web_url":"http://patchwork.ozlabs.org/comment/3684891/","msgid":"<ba768c48-4a1d-4aba-9f01-989688694ae5@redhat.com>","list_archive_url":null,"date":"2026-04-30T18:19:50","subject":"Re: [PATCH] c++/modules: false positive abi_tag mismatch [PR124957]","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/30/26 10:21 AM, Patrick Palka wrote:\n> Tested on x86_64-pc-linux-gnu, does this look OK for trunk/16?\n> Alternatively we could not mangle here and just silently accept the\n> abi_tag mismatch if there's a mangled-ness mismatch; it feels\n> somewhat iffy to mangle something in the middle of streaming.\n\nIt certainly does.  So I think we need to break the connection between \nmangling and the attribute; either inheritance should happen sooner, or \ninherited tags should be separate from explicit tags.  I'm not sure they \nneed to persist past a single mangle_decl anyway.\n\n> -- >8 --\n> \n> Here x in _a.C is defined in terms of A, which has an abi_tag, so it\n> should inherit A's abi_tag.  It turns out this abi_tag propagation\n> happens only during mangling via class.cc:check_abi_tags, and we happen\n> to never mangle x in this TU, so we stream out x with no abi_tag.\n> \n> In _b.C we import and re-export x, and we also happen to mangle x (for\n> arbitrary reasons that I didn't question), which means when we stream it\n> out this time it has an abi_tag.\n> \n> In _c.C we import both versions of x, merge them, during which we\n> compare their abi_tag, notice a mismatch, and diagnose.  But the\n> mismatch is solely due to one version (existing) being mangled, and\n> therefore went through class.cc:check_abi_tags, and the other (decl)\n> not.\n> \n> Idiosyncracies of this testcase aside (like why x gets mangled in _b.C,\n> why we stream in two apparent x's in _c.C), it does seem like this\n> diagnostic routine should be robust to this situation.  To that end this\n> patch makes the routine mangle one of the decls as needed if there's\n> initially an apparent mismatch.\n> \n> \tPR c++/124957\n> \n> gcc/cp/ChangeLog:\n> \n> \t* module.cc (trees_in::check_abi_tags): If only one of the decls\n> \tis mangled, ensure the other one is too before comparing.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* g++.dg/modules/attrib-6_a.C: New test.\n> \t* g++.dg/modules/attrib-6_b.C: New test.\n> \t* g++.dg/modules/attrib-6_c.C: New test.\n> ---\n>   gcc/cp/module.cc                          | 12 ++++++++++++\n>   gcc/testsuite/g++.dg/modules/attrib-6_a.C | 10 ++++++++++\n>   gcc/testsuite/g++.dg/modules/attrib-6_b.C |  8 ++++++++\n>   gcc/testsuite/g++.dg/modules/attrib-6_c.C |  8 ++++++++\n>   4 files changed, 38 insertions(+)\n>   create mode 100644 gcc/testsuite/g++.dg/modules/attrib-6_a.C\n>   create mode 100644 gcc/testsuite/g++.dg/modules/attrib-6_b.C\n>   create mode 100644 gcc/testsuite/g++.dg/modules/attrib-6_c.C\n> \n> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc\n> index 49330312520e..dc9981a5fc24 100644\n> --- a/gcc/cp/module.cc\n> +++ b/gcc/cp/module.cc\n> @@ -12537,6 +12537,18 @@ trees_in::check_abi_tags (tree existing, tree decl, tree &eattr, tree &dattr)\n>     if ((etags == nullptr) != (dtags == nullptr)\n>         || (etags && !attribute_value_equal (etags, dtags)))\n>       {\n> +      if (DECL_ASSEMBLER_NAME_SET_P (STRIP_TEMPLATE (existing))\n> +\t  != DECL_ASSEMBLER_NAME_SET_P (STRIP_TEMPLATE (decl)))\n> +\t{\n> +\t  /* abi_tag gets propagated from components of a decl to the decl\n> +\t     only during mangling, so ensure both decls are mangled before\n> +\t     comparing their abi_tags to avoid false positives.  */\n> +\t  decl_assembler_name (STRIP_TEMPLATE (existing));\n> +\t  decl_assembler_name (STRIP_TEMPLATE (decl));\n> +\t  etags = lookup_attribute (\"abi_tag\", eattr);\n> +\t  dtags = lookup_attribute (\"abi_tag\", dattr);\n> +\t}\n> +\n>         if (etags)\n>   \tetags = TREE_VALUE (etags);\n>         if (dtags)\n> diff --git a/gcc/testsuite/g++.dg/modules/attrib-6_a.C b/gcc/testsuite/g++.dg/modules/attrib-6_a.C\n> new file mode 100644\n> index 000000000000..c63d2cd65c1e\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/attrib-6_a.C\n> @@ -0,0 +1,10 @@\n> +// PR c++/124957\n> +// { dg-do compile { target c++17 } }\n> +// { dg-additional-options \"-fmodules\" }\n> +\n> +export module mod:partition;\n> +\n> +int dummy;\n> +struct [[gnu::abi_tag(\"cxx11\")]] A { int m; };\n> +export inline int A::*x = &A::m;\n> +// x does not get mangled in this TU => abi_tag not propagated to x\n> diff --git a/gcc/testsuite/g++.dg/modules/attrib-6_b.C b/gcc/testsuite/g++.dg/modules/attrib-6_b.C\n> new file mode 100644\n> index 000000000000..c635e159b40b\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/attrib-6_b.C\n> @@ -0,0 +1,8 @@\n> +// PR c++/124957\n> +// { dg-do compile { target c++17 } }\n> +// { dg-additional-options \"-fmodules\" }\n> +\n> +export module mod; // { dg-module-cmi \"mod\" }\n> +export import :partition;\n> +\n> +// x gets mangled in this TU => abi_tag propagated to x\n> diff --git a/gcc/testsuite/g++.dg/modules/attrib-6_c.C b/gcc/testsuite/g++.dg/modules/attrib-6_c.C\n> new file mode 100644\n> index 000000000000..7bfa270f5b47\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/modules/attrib-6_c.C\n> @@ -0,0 +1,8 @@\n> +// PR c++/124957\n> +// { dg-do compile { target c++17 } }\n> +// { dg-additional-options \"-fmodules -fno-module-lazy\" }\n> +\n> +module mod;\n> +import :partition;\n> +\n> +// no bogus abi_tag mismatch error for the imported x's","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=iTvmsMPD;\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=iTvmsMPD","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 [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 4g62Xc0Dd0z1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 04:20:32 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 0AC44436F3EA\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 18:20:30 +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 2182B4BA798B\n for <gcc-patches@gcc.gnu.org>; Thu, 30 Apr 2026 18:19:56 +0000 (GMT)","from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-586-0ZraDZSuMGSPcSW_LV-Xzw-1; Thu, 30 Apr 2026 14:19:54 -0400","by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-8a22dbeeb96so27279186d6.3\n for <gcc-patches@gcc.gnu.org>; Thu, 30 Apr 2026 11:19: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 6a1803df08f44-8b3ff4594e1sm24282866d6.33.2026.04.30.11.19.50\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Thu, 30 Apr 2026 11:19:51 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 0AC44436F3EA","OpenDKIM Filter v2.11.0 sourceware.org 2182B4BA798B"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 2182B4BA798B","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 2182B4BA798B","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777573196; cv=none;\n b=uoVCCNeLZur3W+M8JlTfVgKE5SjHEe/sCMFrpz93HoNL0I/KJlOz9wGSltE5QLcFUK7lBkrzMByyMly8DlfNhlENA+Ex9wtzbp6em7FsL+baXSyuAlgmzeaBHT9oDNsnmQNShiEZo85qfcCcS08Wsvx6aR2FohEG5bXcXeJcgmI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777573196; c=relaxed/simple;\n bh=XLkG+bCK9om07NeorKt2PUOTU9G+9iQ/YBFCsoFke4U=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=sEx/7vnOskVqOdqlRuhHSr6FCeZ+5yBgAz+0ed4AnIfD0F8CoP3C7OIQ6V8ggtDT5rrq9H/+YG7zLI8xByG+6rz4aB+3PRhvwMWIA33kRBxz+zOxX0v6AZ55Fbvjy5suT36h7SSyTRuf/7qlRjLopOPVckLmzt0py/zXUkdoxcA=","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=1777573195;\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 in-reply-to:in-reply-to:references:references;\n bh=EnnZ58g6NDNDgk7/4PGbCME1P1mZSx/O5g1A+A17J4s=;\n b=iTvmsMPDUiVs5OtaVfQYgxRLFgP+B3WDVuYNvXAn9Z0dbQvQ80oF9k5zcS4acAqk97XbyX\n XyeZlrrgBw/DNaUBo+QjhdtIwvVPMKF7flhZBsfrdqGmdIisDyqVi+Eszb83z1RK23KWUt\n 77KRtVv6jIVzFv82/QF4TONYizyDXjs=","X-MC-Unique":"0ZraDZSuMGSPcSW_LV-Xzw-1","X-Mimecast-MFC-AGG-ID":"0ZraDZSuMGSPcSW_LV-Xzw_1777573193","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777573193; x=1778177993;\n h=content-transfer-encoding:in-reply-to:from:content-language\n :references:cc: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=EnnZ58g6NDNDgk7/4PGbCME1P1mZSx/O5g1A+A17J4s=;\n b=XTWJWrT+PfkPNMq3hiKt0LKuGhP/PbpsgdQiMkAmP5J7wFN3dimxPGHDwEiXyVGANN\n 2sUMhcbDPZvu65w1zkmauK0IWIaxaiAcAVIkhu/WS6JU6ilYFlOiXP1yyFfbdMIKPblX\n zdnUjDBJwk26oOrFBICLVomOWRurV3C9zm/fWFcWhprXbqTMjsnWUF6z3lpoDAxDynBw\n lP0JHFo9DuMT4WigaqgeJbd+aegjthLwHb0pIkSmeO5KeXy+qiaR1XiO91ASI4Ty9tRj\n 1d3fQtvhgsBKZ+ZO9n7Gx+XdIti1o5ufbAuaVigZgfxdOMPqzvQrvMGM1rNpdkG6ww8X\n 2+tg==","X-Forwarded-Encrypted":"i=1;\n AFNElJ9sTWCoBJ9O95i3hZ6fYO0FV0x+SK88bxEyHtWKG+3xE27nqc4Lw86yNYiIuuIw0i4wa1MNFm+z33WRZg==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YxsdDJy8G/Ns1f3y6aA/SI4Uq35/WkfiTXYA7TkF0o/u4tKDq1i\n mRwwklJ9R/LVgOv6wnGhCiKWD8HJv+DpYgnRxqrL0JzrXKVhCk5vzGMz3J7/PWVWD3m18pjFEII\n z0vbrGD55ZdgQx8m2hqQ0dvmLJyzWwf1elzKrFTLCGCtOB4W3RQST8ECEtDjL5D/1r7cXYg==","X-Gm-Gg":"AeBDieudfT9EIazUnnDHg7e+ntPOBhxdJr7TNfogJvjvoLOMg6NDoRVKLFWkS2qp8LU\n MSLScvnmvYkv4M9zomRI8echqAzhOEAmh4vOhRzSG3nku3R9tFLlaMdmthqSU2sANi8bmGEkMm5\n OR168ZX9ZSbzL3Zj/zHtgg+lYx9OKsLtHGaonraq1rFhtAnyy68Iro7zCc+RmrR1wHsQ+gN+tDK\n k2HYzIWygo5urSKdl1UtVUpgGhEZTJI+wDd8X50E9Sjqkbez1BJS6I14KG/bkoVQbEs4s+qBXSE\n tjmDiOb1eqAWqp16majwCzgraFFD8pJEY3o46sPA22+HcmPUNfjx5mLC5aZEsRuibrAW1/xt2qK\n crbZ093+0ah5vXn++HxLoeWjBdAqt3FiDUIPC63zMNPDZuoZMVkj1WcwLJeeFTnkzg9XcmrODET\n /pjydrl61CXu43BQm5sMvNSDmAntbGPKTY2fzUCekoiw==","X-Received":["by 2002:a05:6214:1d26:b0:8ae:5fcc:8069 with SMTP id\n 6a1803df08f44-8b3fe77c21amr60614486d6.22.1777573192747;\n Thu, 30 Apr 2026 11:19:52 -0700 (PDT)","by 2002:a05:6214:1d26:b0:8ae:5fcc:8069 with SMTP id\n 6a1803df08f44-8b3fe77c21amr60613666d6.22.1777573192129;\n Thu, 30 Apr 2026 11:19:52 -0700 (PDT)"],"Message-ID":"<ba768c48-4a1d-4aba-9f01-989688694ae5@redhat.com>","Date":"Thu, 30 Apr 2026 14:19:50 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/modules: false positive abi_tag mismatch [PR124957]","To":"Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org","Cc":"nshead@gcc.gnu.org","References":"<20260430142138.1223368-1-ppalka@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<20260430142138.1223368-1-ppalka@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"QAYTbezb_e60X0NPazfqOyFxORvs7mDJ6f-kHqQm8b4_1777573193","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"}}]