https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118920
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:8e99bd447c459d8f298a70355a89122683d7b149 commit r15-8968-g8e99bd447c459d8f298a70355a89122683d7b149 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Wed Mar 26 23:43:36 2025 +1100 c++/modules: Handle conflicting ABI tags [PR118920] The ICE in the linked PR is caused because out_ptr_t inherits an ABI tag in a module that it does not in the importing module. When we try to build a qualified 'const out_ptr_t' during stream-in, we find the existing 'const out_ptr_t' variant type that has been built, but discard it due to having a mismatching attribute list. This causes us to build a new copy of this variant, and ultimately fail a checking assertion due to this being an identical type with different TYPE_CANONICAL. This patch adds checking that ABI tags between an imported and existing declaration match, and errors if they are incompatible. We make use of 'equal_abi_tags' from mangle.cc to determine if we should error; in the case in the PR, because the ABI tag was an implicit tag that doesn't affect name mangling, we don't need to error. To fix the ICE we ensure that (regardless of whether we errored or not) later processing considers the ABI tags as equivalent. PR c++/118920 gcc/cp/ChangeLog: * cp-tree.h (equal_abi_tags): Declare. * mangle.cc (equal_abi_tags): Make external, fix comparison. (tree_string_cmp): Make internal. * module.cc (trees_in::check_abi_tags): New function. (trees_in::decl_value): Use it. (trees_in::is_matching_decl): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/attrib-3_a.H: New test. * g++.dg/modules/attrib-3_b.C: New test. * g++.dg/modules/pr118920.h: New test. * g++.dg/modules/pr118920_a.H: New test. * g++.dg/modules/pr118920_b.H: New test. * g++.dg/modules/pr118920_c.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> Reviewed-by: Jason Merrill <ja...@redhat.com>