https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86590

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |redi at gcc dot gnu.org
          Component|ipa                         |libstdc++

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I've analyzed it more and it is because

      static _GLIBCXX17_CONSTEXPR size_t
      length(const char_type* __s)
      {
#if __cplusplus >= 201703L
        if (__constant_string_p(__s))
          return __gnu_cxx::char_traits<char_type>::length(__s);
#endif
        return __builtin_strlen(__s);
      }

confuses us because of the stupid structure of __constant_string_p.

Is this some odd requirement of O(1) length for constant strings?  Why not
make it constexpr evaluated instead?  Didn't we invent some special
__builtin_constant_p for this?  __constexpr_p ()?  Quoting __constant_string_p:

  template<typename _CharT>
    static _GLIBCXX_ALWAYS_INLINE constexpr bool
    __constant_string_p(const _CharT* __s)
    {
      while (__builtin_constant_p(*__s) && *__s)
        __s++;
      return __builtin_constant_p(*__s);
    }

Reply via email to