Expression evaluation order
Iain Buclaw
ibuclaw at ubuntu.com
Fri Jun 14 02:58:46 PDT 2013
On 14 June 2013 00:09, David Nadlinger <code at klickverbot.at> wrote:
> There is a test in the DMD testsuite that verifies that the evaluation order
> in the following statement
>
> a()[] = b()[] + c()[];
>
> is b, c, a.
>
> I'm trying to figure out why this regressed with the 2.063 merge in LDC, but
> (where) is this specified in the first place?
>
> David
Interesting, that certainly doesn't flag up as a regression in the
2.063 merge in GDC... :o)
However yes, the behaviour relies on the order the sucky X86 ABI
pushes arguments onto the stack (which for this array op is from right
to left). Whereas on *all* other architectures it will execute the
parameters in left to right order, which would be a, c, b in this
case.
--
Iain Buclaw
*(p < e ? p++ : p) = (c & 0x0f) + '0';
More information about the Digitalmars-d
mailing list