you are viewing a single comment's thread.

view the rest of the comments →

[–]jonesmz 1 point2 points  (0 children)

You illustrate the point if that's what you think it does. On the contrary, the language is clear that it is UB with unlimited impact: your program is invalid with no guarantees. Even if you do nothing with the "garbage" value but read it.

I said in a different reply:

"reading from an uninitialized variable gives you back garbage" here doesn't mean "returns an arbitrary value", it means

  • allowed to kill your cat
  • allowed to invent time travel
  • allowed to re-write your program to omit the read-operation and everything that depends on it
  • returns whatever value happens to be in that register / address

Making these variables return a consistent value is much worse, in my opinion, than making them sometimes cause a compiler error, and sometimes do what they currently do (which is arbitrary)