[Bug c++/85156] [8 Regression] ICE with -O1 -g: gimplification failed

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 3 10:06:00 GMT 2018


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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is not just ICE, but also a wrong-code starting with GCC 4.3:
int x, y;

__attribute__((noipa)) int
foo (int z)
{
  if (__builtin_expect (x ? y != 0 : 0, z++))
    return 7;
  return z;
}

int
main ()
{
  x = 1;
  asm volatile ("" : "+m" (x), "+m" (y));
  if (foo (10) != 11)
    __builtin_abort ();
  return 0;
}

The side-effects of the second __builtin_expect argument are evaluated multiple
times.


More information about the Gcc-bugs mailing list