Multiple assignment

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 25 18:10:59 PST 2011


On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote:
> On 02/25/2011 05:09 PM, bearophile wrote:
>  >      int j;
>  >      int[2] y;
>  >      y[j] = j = 1;
> 
> I think that's undefined behavior in C and C++. It is not defined
> whether j's previous or past value is used in y[j].
> 
> I would expect the situation be the same in D.

No, that should be perfectly defined. What's undefined is when you do something 
like func(j, y[j]). The evaluation order of the function arguments is undefined. 
However,  the evaluation order when dealing with an assignment should be defined. 
I _could_ be wrong about that, but there's no question that the assignments 
themselves are guaranteed to be done in right-to-left order.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list