https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92462
Richard Earnshaw <rearnsha at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #6 from Richard Earnshaw <rearnsha at gcc dot gnu.org> --- (In reply to Aleksei Voitylov from comment #4) > Isn't > > uint32_t cur = *aligned_dest; > uint8_t* cur_as_bytes = reinterpret_cast<uint8_t*>(&cur); > > the very definition of the pointer aliasing? No. the standard says (paraphrasing, read the standard for the exact words) that pointers to different types cannot point to the same object, unless one of the pointers is a pointer to char. As previously explained, uint8_t is not a char. So the compiler is allowed to assume that, because cur is not modified inside the loop it can be lifted out entirely and treated as unchanging.