On 3/27/25 8:05 AM, Nathaniel Shead wrote:
On Thu, Mar 27, 2025 at 08:02:20AM -0400, Jason Merrill wrote:
On 3/26/25 9:24 AM, Nathaniel Shead wrote:
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?
-- >8 --
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.
@@ -1738,7 +1737,8 @@ equal_abi_tags (tree t1, tree t2)
if (len1 != v2->length())
return false;
for (unsigned i = 0; i < len1; ++i)
- if (tree_string_cmp (v1[i], v2[i]) != 0)
+ if (strcmp (TREE_STRING_POINTER (v1[i]),
+ TREE_STRING_POINTER (v2[i])) != 0)
How does this "fix" the comparison? It looks equivalent to me.
I was getting segfaults in my testcases; I think this was unfortunate
conversions to void*, and intended was 'tree_string_cmp(&v1[i], &v2[i])'.
But rather than messing around with that I elected to go with the more
obviously correct approach.
Makes sense, the patch is OK.
Jason