On Saturday, 29 September 2012 at 23:02:08 UTC, Timon Gehr wrote:
On 09/30/2012 12:51 AM, Ali Çehreli wrote:
Disclaimer: I assume that D's rules are the same as C and C++ here.


C and C++ do not have struct literals and if I am not mistaken,
constructor invocation is a sequence point.

S(4, s.a, 6) is a struct literal here, not a constructor call (because structure S doesn't define any constructors). C has compound literals which is close to D struct literals.

Besides, this does not make any sense, what is the relevant part of the standard?

The standard states for assign expression (in $6.15.6) that "the side effect of updating the stored value is sequenced after the value computations of the left and the rights operands. The evaluations of the operands are unsequenced". This means that a compiler can evaluate either first and the second operand, or the second and the first. In any case it can store value only after evaluations of both operands which means that value 4 cannot be assigned to s.a when S(4, s.a, 6) is evaluated. Actually, it is a bug.

Reply via email to