> I'll wager you assumed all compilers process this line in the same way
You would lose that wager.
What I mean by "I do know the answer" is that I know that this is undefined behavior and why it is undefined behavior and that different compilers can give different results and also that even if I test the compiler I use to see what it does I can't count on that not changing any time the compiler gets updated.
Fair, but that was not clear to me that that's what you meant. It's clear that others interpreted it the way you intended too (since there are multiple replies saying exactly what you said) but I also don't think I'm the only one who misinterpreted. Sorry that I did.
Seems fitting in a thread about undefined behavior
I think you're misinterpreting "I know the answer". The GP is suggesting rewriting it, so the know the issue.
Re:Int a = 5; a = a++ + ++a; a =? (2011)
by 1718627440 on Friday May 15, 2026 @08:32AM
(#48147819)
> Except you don't!
Except you can do, because "The answer is that this isn't a valid C program." is a sentence you can know.
If you claim to know the answer you've made a grave mistake and fooled yourself.
If you ran the code in a compiler and used that to conclude "this is the answer" rather than "this is an answer" then now is a great time to learn how easy it is to fool yourself. You just need you ask yourself what assumptions you made. I'll wager you assumed all compilers process this line in the same way.
Or just RTFA, or Susam's, as that's exactly what they are about. They explain why this is undefined behavior.