https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108094
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- The compiler optimizes it out as it's UBSAN and provides you a reasonable warning.
marxin at gcc dot gnu.org via Gcc-bugs Wed, 14 Dec 2022 02:21:42 -0800
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108094
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- The compiler optimizes it out as it's UBSAN and provides you a reasonable warning.