https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103699
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> --- There is -Wstrict-aliasing warning, with 3 different levels from most to least aggressive, see gcc documentation. But that warns mostly on the casts rather than when performing the invalid access. There are plans for a strict aliasing sanitizer, but it is a lot of work and hard to do right.