"ljh131" <lj****@gmail.com> schrieb im Newsbeitrag
news:11**********************@g49g2000cwa.googlegr oups.com...
i found something wrong code.
int i = 0;
i = i++;
is it standard c++? peoples say i == 1 in most compilers but anothers
not the same. if so, may be it's not standard code, however i want know
positively.
Yes, it is standard C++, but the behaviour is not defined by the standard.
In the statement 'i = i++', there is no sequence point and i is modified
more than once. Many compilers might create code such that finaly i == 1,
but it is easy to imagine a sequence of code, that results in i == 0:
1. Evaluate the expression i
2. Increment i
3. Assign the result of step 1 to i
So remember what they tell the kids in TV -- "Don't do that at work"
HTH
Heinz