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

--- Comment #3 from Alfred Agrell <blubban at gmail dot com> ---
strcmp (c, "ABCDEFGHabcdefgh") || strcmp (c, "ABCDEFGHfoobar") can safely be
optimized to 1, you're thinking of strcmp(c, "ABCDEFGHabcdefgh")==0 ||
strcmp(c, "ABCDEFGHfoobar")==0.

Optimizing to multi-byte reads would be a wrong-code. If strcmp(c, "1234567")
does an eight-byte read, it'll segfault if c is {'e',0} four bytes before an
unmapped page.

Even if limiting it to aligned reads (can't segfault without crossing a page),
it'll annoy Valgrind.

(Large reads would be safe if lhs is char[8] and not char*, or if strlen is
checked before doing those reads, but both of those feel unlikely to me.)

Reply via email to