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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xry111 at gcc dot gnu.org

--- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
FWIW there are too many online articles discussing aliasing rule but failing to
get the concept correct.  As Andrew has explained the aliasing rule is all
about the type used for accessing a lvalue, it's not related to pointer
casting, at all.

Checking against pointer casting is just a heruistic way for finding aliasing
bugs and it may have false positives or false negatives.  This renders
-Wstrict-aliasing almost useless.

If a pointer cast to (T *) made the type alias with T, the aliasing rule would
be meaningless because in a different TU (that the compiler cannot see) any
pointer can be casted to anything.  For example, *everything* is casted to
(char *) in Glibc memcpy() thus *everything* would be aliasing.  This would be
obviously irrational.

Reply via email to