https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117490
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Uecker <uec...@gcc.gnu.org>: https://gcc.gnu.org/g:8b02cc9a4f2b8db48da2a3460655b062eaa147ba commit r15-5470-g8b02cc9a4f2b8db48da2a3460655b062eaa147ba Author: Martin Uecker <uec...@tugraz.at> Date: Fri Nov 8 18:46:10 2024 +0100 c: fix incorrect TBAA for tagged types across translation units [PR117490] Two different declarations of tagged types in the same translation unit are incompatible in C before C23 and without tag also in C23. Still, two such types can be compatible to the same tagged type in a different translation unit, but this means that pointers can alias. typedef struct { int i; } s1; typedef struct { int i; } s2; int f(s1 *p1, s2 *p2) { p1->i = 2; p2->i = 3; // p2->i can alias p1->i return p1->i; } We need to assign the same TYPE_CANONICAL to both types. This patch fixes this for C23 and types without tag by also forming equivalence classes for such types based on their structure as already done for types with tag. Because this change exposes checking errors related to flexible array members (cf. PR113688), one test is restricted to C17 for now. PR c/117490 gcc/c/ChangeLog: * c-typeck.cc (tagged_types_tu_compatible): Form equivalence classed for tagless types in C23. gcc/testsuite/ChangeLog: * gcc.dg/gnu23-tag-alias-4.c: Adapt test. * gcc.dg/gnu23-tag-alias-7.c: Adapt test. * gcc.dg/guality/zero-length-array.c: Restrict to c17. * gcc.dg/pr117490.c: New test.