[Bug c++/91987] -fstrict-eval-order issues

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 5 07:53:00 GMT 2019


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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another testcase, another reason:
int a[4] = { 1, 2, 3, 4 };
int b[4] = { 5, 6, 7, 8 };

int
foo (void)
{
  int *x = a;
  int r = x[(x = b, 3)];
  if (x != b)
    __builtin_abort ();
  return r;
}

int
main ()
{
  if (foo () != 3)
    __builtin_abort ();
}

The problem here is that we somewhere fold the x[(x = b, 3)] which with
-fstrong-eval-order should have well defined ordering between x and (x = b, 3)
into
*(x + (x = b, 3)) which is undefined.


More information about the Gcc-bugs mailing list