[Bug c++/120395] Calls to std::__is_constant_evaluated() hurt codegen at -O0

2025-05-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120395

--- Comment #3 from Jonathan Wakely  ---
Thanks!

[Bug c++/120395] Calls to std::__is_constant_evaluated() hurt codegen at -O0

2025-05-22 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120395

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
   Target Milestone|--- |16.0
 Resolution|--- |FIXED

--- Comment #2 from Jason Merrill  ---
Fixed by r16-828-g26b50c5fed8b03 (wrong PR number in the comment, oops)

[Bug c++/120395] Calls to std::__is_constant_evaluated() hurt codegen at -O0

2025-05-22 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120395

Jason Merrill  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org
 Ever confirmed|0   |1
   Last reconfirmed||2025-05-22
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
 Status|UNCONFIRMED |ASSIGNED

[Bug c++/120395] Calls to std::__is_constant_evaluated() hurt codegen at -O0

2025-05-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120395

--- Comment #1 from Jonathan Wakely  ---
This isn't actually related to the builtin, we get the same thing for any
always_inline function that returns a constant:

void x(int);

[[gnu::always_inline]]
inline bool always_true() { return true; }

struct Iter
{
typedef int value_type;

int& operator*() const;
Iter& operator++();
bool operator!=(const Iter&) const;
};

void f(Iter first, Iter last)
{
if (__is_trivial(Iter::value_type))
if (always_true())
return;

// unreachable dead code!
for (; first != last; ++first)
x(*first);
}

So there's probably a dup of this.