[Bug c++/91987] -fstrict-eval-order issues
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Oct 5 08:24:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91987
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another testcase for the same reason as above:
int a[4] = { 1, 2, 3, 4 };
int c;
int
main ()
{
int *x = a;
c = 1;
int r = (c = 4, x)[(c *= 2, 3)];
if (c != 8 || r != 3)
__builtin_abort ();
c = 1;
r = (c = 3, 2)[(c *= 2, x)];
if (c != 6 || r != 2)
__builtin_abort ();
}
If we want to represent E1[E2] for non-array E1/E2 as *(E1+E2), we need to
force the evaluation of E1's side-effects, but not just those seen under
TREE_SIDE_EFFECTS, some other way. Perhaps SAVE_EXPR<E1>, *(SAVE_EXPR<E1>+E2).
Thoughts on this?
More information about the Gcc-bugs
mailing list