Quote:Original post by ToohrVyk
Quote:Original post by M2tM
[about i = (1, i++);]
1;
i++;
i = i;
Note that it may also execute as:
1;
int temp = i;
i++;
i = temp;
The order of execution between the = and the ++ operators is unspecified, therefore the code here is non-deterministic.
Indeed, it may work on some configurations, it may not. Don't do it.
Thanks for the extra info, and yes, it would be the same problem as i = i++;
Now I have a question though, and it's a simple one but one I just haven't really looked into. Do brackets enable this to be safe?
i = (i++);
My gut reaction is no, especially if a temporary storage space is used exactly as you have there.
The other thing playing in my mind is that maybe the brackets ensure that the operation completes and somehow returns the complete value. I don't know if this is defined in the standards, I'd check it in google but I don't know what I'd search for.
*edit: It seems it goes based on something called "sequence points" I'll look that up, but feel free to supply a description or links.
_______________________"You're using a screwdriver to nail some glue to a ming vase. " -ToohrVyk