https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88398
--- Comment #32 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> --- (In reply to Wilco from comment #31) > (In reply to Jiu Fu Guo from comment #30) > > (In reply to Wilco from comment #29) > > > > The key question remains whether it is legal to assume the limit implies > > > the > > > memory is valid and use wider accesses. > > > If unaligned access is support, it would be valid to access the memory. > > Otherwise, checking like ((pb&7) == (cur & 7)) would cost an additional > > test, and it may not sure likely to be true. > > If both pointers are aligned it would be safe indeed, but if unaligned they > will access up to 7 bytes after the first match. And that's not safe without > knowing the underlying buffer bounds. See eg. comment #3. Extra information is needed, before using widen reading: if the pointers are aligned, and make sure the underlying buffer is large enough. Additional checking is needed and the original loop may need to keep.