https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78156
--- Comment #3 from Pauli <suokkos at gmail dot com> --- Could __builtin_constant_p help to select different code for compile time and runtime? Something like: string_view(const _CharT* __str) : _M_len(/*null check*/__builtin_constant_p(__str /*or __str[0]?*/) ? recursive_strlen<_CharT>(__str) : /*or traits_type::__constexpr_length()*/ traits_type::length()), _M_str(__str) {}