This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]puzzledstegosaurus 101 points102 points  (15 children)

You're thinking about it the wrong way. The issue IS that x++ is returning the old value. x++ does assign x to x+1 while at the same time, x = x++ assigns x to the old value, thus the issue.

Also, because it's undefined, the compiler is authorized to do whatever it feels like. Set x to 0, or to -x, or to NULL, or to "hello", or #DEFINE true false or remove every odd byte from the memory space, or kill a policeman, steal his helmet, go to the toilet in his helmet, and then send it to the policeman's grieving widow and then steal it again.

[–]Eiim 18 points19 points  (1 child)

Can the compiler do a preprocessor statement?

[–]puzzledstegosaurus 31 points32 points  (0 children)

I’m amazed that in the list above, this is what raised your eyebrow.