logoalt Hacker News

godelskitoday at 12:51 AM3 repliesview on HN

  > The other half is "but I do know the answer
Except you don't!

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.

  | The first principle is that you must not fool yourself — and you are the easiest person to fool.
  - Feynman

Replies

tzstoday at 6:24 AM

> 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.

show 1 reply
1718627440today at 12:32 PM

> 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.

benj111today at 8:31 AM

I think you're misinterpreting "I know the answer". The GP is suggesting rewriting it, so the know the issue.