On Sat, 28 Feb 2026, Martin Uecker wrote: > When computing TYPE_CANONICAL we form equivalence classes of types > ignoring some aspects. In particular, we treat two structure / union > types as equivalent if a member is a pointer to another tagged type > which has the same tag, even if this pointed-to type is otherwise not > compatible. The fundamental reason why we do this is that even in a > single TU the equivalence class needs to be consistent with compatibility > of incomplete types across TUs. (LTO globs such pointers to void*). > > The bug is that the test incorrectly treated also two pointed-to types > without tag as equivalent. One would expect that this just pessimizes > aliasing decisions, but due to how the middle-end handles TBAA for > components of structures, this leads to wrong code. > > PR c/122572 > > gcc/c/ChangeLog: > * c-typeck.cc (tagged_types_tu_compatible_p): Fix check. > > gcc/testsuite/ChangeLog: > * gcc.dg/pr122572.c: New test. > * gcc.dg/pr123356-1.c: New test.
OK. -- Joseph S. Myers [email protected]
