https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97843

--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Alex from comment #2)
> The arithmetic equivalent would be for:
> X += 4/2
> To be produce:
> Immediate load Register with 4
> Add register with 4 in it to x
> Divide register with 4 in it by 2
> Resulting in x being increased by 4 instead of 2
> 
> 10.2.3 Binary expressions EXCEPT for AssignExpression are left to right
> 
> 10.2.7 says operand order is undefined
> 
> Nowhere does the spec say that the assignment operator has to happen after
> operand evaluation. I think this is a hole in the spec.

The equivalent code that `bytes ~= bytes.sum` equates to is:

ref ubyte[] extend(ref ubyte[] bytes)
{
    bytes.length += 1;
    bytes[$-1] = 0xde;
    return bytes;
}

extend(bytes)[bytes.length] = bytes.sum;

Which is also LTR evaluation, so everything is consistent so far.

Reply via email to