Order of evaluation of a += a++;
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 31 01:17:31 PDT 2015
On 3/31/15 12:18 AM, Orvid King wrote:
>
> I might be a bit confused here, but from what you're saying:
> b += a++;
> and
> b += ++a;
>
> Are doing the same thing in DMD?
No. Lowering of e1 += e2++ is:
e1 += e2++
-\>
(ref a, b) { a = (cast(typeof(a)) (a + b); }(
e1,
(ref a) { auto x = a; ++a; return x; }(e2)
)
whereas lowering of e1 += ++e2 is:
e1 += ++e2
-\>
(ref a, b) { a = (cast(typeof(a)) (a + b); }(
e1,
(ref a) { ++a; return a; }(e2)
)
Andrei
More information about the Digitalmars-d
mailing list