[Bug c++/80265] __builtin_{memcmp,memchr,strlen} are not usable in constexpr functions
palves at redhat dot com
gcc-bugzilla@gcc.gnu.org
Fri Mar 23 12:58:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80265
--- Comment #30 from Pedro Alves <palves at redhat dot com> ---
> I suspect that wouldn't work, because we'd need to check whether the
> elements the iterator range point-to are themselves constant.
I would like to add that the char_traits trick handles this by doing exactly
that, checking whether all elements in the string/array are constant
(__constant_string_p/__constant_char_array_p), before deferring to the naive
for loop; a __constexpr_memcmp would do the same before falling back to
__builtin_memcmp. In my testing back then, the compiler/optimizer always
folded away these loops.
More information about the Gcc-bugs
mailing list