[Bug middle-end/78809] Inline strcmp with small constant strings
qing.zhao at oracle dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 24 19:04:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78809
--- Comment #15 from Qing Zhao <qing.zhao at oracle dot com> ---
(In reply to Wilco from comment 14)
> The only reason we have to do a character by character comparison is because we
> cannot read beyond the end of a string. However when we know the size or
> alignment we can safely process a string one word at a time.
is it possible that “NULL_terminator” is in the middle of the string even
though we
know the size or alignment? for example:
const char s[8] = “abcd\0abc”; // null byte in the middle of the string
int f2(void) { return __builtin_strcmp(s, "abc") != 0; }
int f3(void) { return __builtin_strcmp(s, “abc”); }
can either of the above f2 or f3 been optimized to memcmp? seems not.
More information about the Gcc-bugs
mailing list