d: Wrong evaluation order of binary expressions (PR101640)
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 27 Jul 2021 11:24:34 +0000 (13:24 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 28 Jul 2021 11:13:06 +0000 (13:13 +0200)
commit54ec50bada94a8ff92edb04ee5216c27fa4bf942
tree41d105545a3cacb3ca44c1487c20ef03a29d640c
parentc936c39f86c74b3bfc6831f694b3165296c99dc0
d: Wrong evaluation order of binary expressions (PR101640)

The use of fold_build2 can in some cases swap the order of its operands
if that is the more optimal thing to do.  However this breaks semantic
guarantee of left-to-right evaluation in D.

PR d/101640

gcc/d/ChangeLog:

* expr.cc (binary_op): Use build2 instead of fold_build2.

gcc/testsuite/ChangeLog:

* gdc.dg/pr96429.d: Update test.
* gdc.dg/pr101640.d: New test.
gcc/d/expr.cc
gcc/testsuite/gdc.dg/pr101640.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr96429.d