[Bug d/100769] [D] memcmp() == 0 for small constant strings not folded
witold.baryluk+gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 26 14:40:47 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100769
--- Comment #1 from Witold Baryluk <witold.baryluk+gcc at gmail dot com> ---
A typo in the example (godbolt is good), I forgot the `.ptr`:
extern(C) int memcmp(const void *s1, const void *s2, size_t n);
int recognize3(const char* s) {
return memcmp(s, "stract class".ptr, 12) == 0;
}
casting to ubyte*, or void*, doesn't change anything really.
options: -O3 -frelease -fno-semantic-interposition
tested on amd64, Debian / Linux.
More information about the Gcc-bugs
mailing list