aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/expr.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-07-27 13:24:34 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-07-28 13:13:06 +0200
commit54ec50bada94a8ff92edb04ee5216c27fa4bf942 (patch)
tree41d105545a3cacb3ca44c1487c20ef03a29d640c /gcc/d/expr.cc
parentc936c39f86c74b3bfc6831f694b3165296c99dc0 (diff)
downloadgcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.zip
gcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.tar.gz
gcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.tar.bz2
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.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r--gcc/d/expr.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index e76cae9..b78778e 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -157,7 +157,7 @@ binary_op (tree_code code, tree type, tree arg0, tree arg1)
eptype = type;
}
- ret = fold_build2 (code, eptype, arg0, arg1);
+ ret = build2 (code, eptype, arg0, arg1);
}
return d_convert (type, ret);