[Bug libstdc++/78156] constexpr basic_string_view::basic_string_view(const charT *) calls non-constexpr char_traits::length
suokkos at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Nov 6 14:30:00 GMT 2016
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)
{}
More information about the Gcc-bugs
mailing list