I've experimented with the code
int i = 3; i = i++;on several compilers. Some gave i the value 3, some gave 4, but one gave 7. I know the behavior is undefined, but how could it give 7?
Undefined behavior means anything can happen. See questions 3.9 and 11.33. (Also, note that neither i++ nor ++i is the same as i+1. If you want to increment i, use i=i+1 or i++ or ++i, not some combination. See also question 3.12.)
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995 // mail feedback