From fa192a02537d73947ce2fb8ca6e8fb9f0f161d42 Mon Sep 17 00:00:00 2001 From: Alex Burton Date: Tue, 17 Nov 2020 22:07:08 +1100 Subject: [PATCH 1/2] improve define behaviour of assign expression --- spec/expression.dd | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/expression.dd b/spec/expression.dd index 6d29ce05d5..e2f35d9eae 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -261,6 +261,18 @@ $(GNAME AssignExpression): occurs. The resulting expression is a modifiable lvalue. ) + $(P Operands of an assign expression are evaluated before the assign expression. + The expression) + -------------- + a op= b + -------------- + + is exactly the same as: + + -------------- + a = a op b + -------------- + $(UNDEFINED_BEHAVIOR If either operand is a reference type and one of the following: $(OL From 600081cceb9601d36c27b4475f4c16e58e7d8032 Mon Sep 17 00:00:00 2001 From: Alex Burton Date: Wed, 18 Nov 2020 21:42:57 +1100 Subject: [PATCH 2/2] specify that operands/arguments evaluated before operators/functions --- spec/expression.dd | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/spec/expression.dd b/spec/expression.dd index e2f35d9eae..2502a0f6c7 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -75,6 +75,8 @@ subexpression `h()` has no smallest short-circuit expression. $(H2 $(LNAME2 order-of-evaluation, Order Of Evaluation)) +$(P Operands are evaluated before operators are executed. Arguments are evaluated before functions are called.) + $(P Built-in prefix unary expressions `++` and `--` are evaluated as if lowered (rewritten) to assignments as follows: `++expr` becomes `((expr) += 1)`, and `--expr` becomes `((expr) -= 1)`. Therefore, the result of prefix `++` and `--` is the lvalue after the side effect has been @@ -261,18 +263,6 @@ $(GNAME AssignExpression): occurs. The resulting expression is a modifiable lvalue. ) - $(P Operands of an assign expression are evaluated before the assign expression. - The expression) - -------------- - a op= b - -------------- - - is exactly the same as: - - -------------- - a = a op b - -------------- - $(UNDEFINED_BEHAVIOR If either operand is a reference type and one of the following: $(OL