[Bug c++/106654] [C++23] P1774 - Portable assumptions

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Sep 14 11:26:09 GMT 2022


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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> On the C++ frontend side I'd simply handle
> 
> [[assume(expr)]]
> 
> as if 'expr' were in a lambda -> bool with everything captured by value.

... because it seems (ick!)

void foo()
{
  int i = 0;
[[assume(++i == 1)]];
  if (i != 0)
    std::abort ();
}

needs to work.  We couldn't let that ++i "escape" to GENERIC/GIMPLE, even
when protected with if (.IFN_ASSUME ()) it would create ugly PHIs.


More information about the Gcc-bugs mailing list