[Bug c++/108243] [10/11/12/13 Regression] Missed optimization for static const std::string_view(const char*)
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 4 13:21:46 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108243
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC can't even optimize it properly for C++20 when using if-consteval:
static constexpr unsigned long length(const char* s)
{
#ifndef FIX
if consteval {
unsigned long n = 0;
while (*s++)
++n;
return n;
}
#endif
return __builtin_strlen(s);
}
More information about the Gcc-bugs
mailing list