[Bug c++/70816] bogus error __builtin_strcmp is not a constant expression in a constexpr function

2022-01-26 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816

Martin Sebor  changed:

   What|Removed |Added

   Assignee|msebor at gcc dot gnu.org  |unassigned at gcc dot 
gnu.org
 Status|ASSIGNED|NEW

--- Comment #5 from Martin Sebor  ---
I'm not working on this anymore.

[Bug c++/70816] bogus error __builtin_strcmp is not a constant expression in a constexpr function

2021-12-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816

--- Comment #4 from Jonathan Wakely  ---
Our std::char_traits has similar branches for constant evaluation (and the rest
of the library does too for memcpy etc.)

[Bug c++/70816] bogus error __builtin_strcmp is not a constant expression in a constexpr function

2021-12-15 Thread ldionne.2 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816

Louis Dionne  changed:

   What|Removed |Added

 CC||ldionne.2 at gmail dot com

--- Comment #3 from Louis Dionne  ---
We are having to add a workaround in libc++ to implement constexpr std::string:
https://reviews.llvm.org/D115795

It would be awesome if this could be fixed! (if so, please drop us a line and
we'll remove our workaround)

[Bug c++/70816] bogus error __builtin_strcmp is not a constant expression in a constexpr function

2021-03-14 Thread arthur.j.odwyer at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816

Arthur O'Dwyer  changed:

   What|Removed |Added

 CC||arthur.j.odwyer at gmail dot 
com

--- Comment #2 from Arthur O'Dwyer  ---
Confirmed, I'm also seeing this in C++20 mode. This affects libc++'s
 `char_traits::length(const char *)`.

Example test case: https://godbolt.org/z/MTq1ex

[Bug c++/70816] bogus error __builtin_strcmp is not a constant expression in a constexpr function

2016-06-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2016-06-08
 Ever confirmed|0   |1
  Known to fail|6.0 |6.1.0, 7.0

--- Comment #1 from Martin Sebor  ---
The same limitation affects other string builtins such as __builtin_strlen or
__builtin_strchr.

$ cat cst.C && /home/msebor/build/gcc-6-branch/gcc/xgcc
-B/home/msebor/build/gcc-6-branch/gcc -S -Wall -Wextra -Wpedantic cst.C
-fdump-tree-optimized=/dev/stdout -o/dev/stdout
constexpr int chr (int c)
{
  const char a[] = "123";
  return __builtin_strchr (a, c) - a;
}

constexpr int i = chr ('3');

constexpr int cmp (const char *a)
{
  const char b[] = "123";
  return __builtin_strcmp (a, b);
}

constexpr int j = cmp ("345");

constexpr unsigned len ()
{
  const char s[] = "123";
  return __builtin_strlen (s);
}

constexpr unsigned n = len ();
.file   "cst.C"
cst.C:7:23:   in constexpr expansion of ‘chr(51)’
cst.C:4:27: error: ‘__builtin_strchr(((const char*)(& a)), 51)’ is not a
constant expression
   return __builtin_strchr (a, c) - a;
  ~^~
cst.C:15:23:   in constexpr expansion of ‘cmp(((const char*)"345"))’
cst.C:12:27: error: ‘__builtin_strcmp(((const char*)"345"), ((const char*)(&
b)))’ is not a constant expression
   return __builtin_strcmp (a, b);
  ~^~
cst.C:23:28:   in constexpr expansion of ‘len()’
cst.C:20:27: error: ‘__builtin_strlen(((const char*)(& s)))’ is not a constant
expression
   return __builtin_strlen (s);
  ~^~~