https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122572

--- Comment #24 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:065bbf5c5f8ce438f4cab94eec695e01e089c443

commit r16-7871-g065bbf5c5f8ce438f4cab94eec695e01e089c443
Author: Martin Uecker <[email protected]>
Date:   Tue Jan 6 19:26:42 2026 +0100

    c: Fix wrong code related to TBAA for components of structure types 1/2
[PR122572]

    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.

Reply via email to