https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117490
--- Comment #5 from Martin Uecker <muecker at gwdg dot de> --- Am Freitag, dem 08.11.2024 um 14:22 +0000 schrieb rguenth at gcc dot gnu.org: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117490 > > Richard Biener <rguenth at gcc dot gnu.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |rguenth at gcc dot gnu.org > > --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- > This seems to make the alias relationship non-transitive which IMO is bogus. > > The frontend needs to arrange for the types of s1 and s2_alt to have the > same TYPE_CANONICAL to fix this issue. > Fixing this issue (for type compatibility in general and not aliasing specifically) was my main motivation for proposing the C23 changes, which were then only partially accepted (only for types with tags). BTW: The same bug also appears with types with tags before C23, one just has to work a bit harder to come up with a test case: typedef struct tag { int i1; } s1; int f2(s1 *s1p, struct tag { int i1; } *s2p) { s1p->i1 = 2; s2p->i1 = 3; return s1p->i1 * 3; } https://godbolt.org/z/r7rj8Ms7n In any case, it seems we need to set TYPE_CANONICAL also for types without tag and also in previous language modes. This should be relatively easy by adapting the new C23 code...