This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80265] __builtin_{memcmp,memchr,strlen} are not usable in constexpr functions


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]