Original Post
i = i++;
I'm sure we've all seen that. Assuming i is a primitive type (such as int), is the behavior undefined? I've read that it is indeed undefined since the = operator does not introduce a sequence point (*). Is this correct? I don't fully understand why, though. The post-fix ++ operator increments by 1 and returns the old value, right? And then this old value will be assigned to i, effectively nullifying the change. (*) Unless i is a non-primitive type and operator=() is overloaded, apparently. In which case it would introduce a sequence point because it is treated as a normal function, and therefore i++ would be fully evaluated before operator=() is actually called. Would any of the C++ gurus like to shed some light on this?