https://issues.dlang.org/show_bug.cgi?id=14364
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #1 from [email protected] --- (In reply to Shammah Chancellor from comment #0) > int ret = 5; > ret += ((ret++ == 5) ? (ret += 3) : (ret -= 11)) + ret; > assert(ret == 23); To arrive at 23 I guess sdc see these values: 5 + 6 + 3 + 9 = 23 ret += ((ret++ == 5) ? (ret += 3) : (ret -= 11)) + ret; That is, sdc takes the value of the lhs before evaluating the rhs. dmd arrives at 27 = 9 + 6 + 3 + 9, meaning it evaluates the rhs before taking the value of the lhs. The spec has something to say about that[1]: > The following binary expressions are evaluated in an implementation-defined > order: > > AssignExpression, function arguments > > It is an error to depend on order of evaluation when it is not specified. For > example, the following are illegal: > > i = i++; So, both sdc and dmd are right and the test case is "illegal". Closing as invalid. [1] http://dlang.org/expression.html --
