MaskRay added a comment.

https://reviews.llvm.org/rC347417 makes `constexpr string_view service = "HELLO 
WORD SERVICE"` (P0426) broken with libstdc++

  % cat a.cc
  constexpr bool __constant_string_p(const char *__s) {
    while (__builtin_constant_p(*__s) && *__s)
      __s++;
    return __builtin_constant_p(*__s);
  }
  
  constexpr bool n = __constant_string_p("a");



  % fclang++ -std=c++17 -fsyntax-only a.cc
  a.cc:1:16: error: constexpr function never produces a constant expression 
[-Winvalid-constexpr]
  constexpr bool __constant_string_p(const char *__s) {
                 ^
  a.cc:2:10: note: subexpression not valid in a constant expression
    while (__builtin_constant_p(*__s) && *__s)
           ^
  a.cc:7:16: error: constexpr variable 'n' must be initialized by a constant 
expression
  constexpr bool n = __constant_string_p("a");
                 ^   ~~~~~~~~~~~~~~~~~~~~~~~~
  a.cc:2:10: note: subexpression not valid in a constant expression
    while (__builtin_constant_p(*__s) && *__s)
           ^
  a.cc:7:20: note: in call to '__constant_string_p(&"a"[0])'
  constexpr bool n = __constant_string_p("a");
                     ^
  2 errors generated.

Fourth time should be a charm...


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54355/new/

https://reviews.llvm.org/D54355



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to