https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122572
--- Comment #25 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Uecker <[email protected]>: https://gcc.gnu.org/g:d5c50c75f05c783e4b2dd8599f6d16f13961e5f1 commit r16-7872-gd5c50c75f05c783e4b2dd8599f6d16f13961e5f1 Author: Martin Uecker <[email protected]> Date: Fri Feb 20 17:19:10 2026 +0100 c: Fix wrong code related to TBAA for components of structure types 2/2 [PR122572] Given the following two types, the C FE assigns the same TYPE_CANONICAL to both struct bar, because it treats pointer to tagged types with the same type as compatible (in this context). struct foo { int y; }; struct bar { struct foo *c; } struct foo { long y; }; struct bar { struct foo *c; } get_alias_set records the components of aggregate types, but only considers the components of the canonical version. To prevent miscompilation, we create a modified canonical type where we change such pointers to void pointers. PR c/122572 gcc/c/ChangeLog: * c-decl.cc (finish_struct): Add distinct canonical type. * c-tree.h (c_type_canonical): Prototype for new function. * c-typeck.cc (c_type_canonical): New function. (ptr_to_tagged_member): New function. gcc/testsuite/ChangeLog: * gcc.dg/pr123356-2.c: New test. * gcc.dg/struct-alias-2.c: New test.
