I have never understood why it's such a common "joke" to say that
"undefined behavior" means <insert physically impossible and completely
wacky thing here>.
Because it highlights the fact that no list of possible
behaviors can be exhaustive.
Sure, the letter of the expression "undefined behaviour" might "allow"
the compiler to do *anything*. However, I think that the spirit of that
expression simply means "the effects can be random because the values
cannot be guaranteed". In the specific context of trying to read an
uninitialized variable it means that the variable could have any value,
and no specific value is specified by the standard.
Or that it could cause a hardware trap. As long as you're just
reading, those are probably the only possible behaviors (but I'm
not 100% sure about it).
It certainly does
not mean that trying to read an uninitialized variable will "call
NORAD and start WW3".
Why can't people just tell what may happen *in practice* instead of
coming up with all the tired overly-repeated jokes?
Well, I've seen dereferencing an uninitialized pointer hang the
machine, so that you had to power it off and then on again to do
anything with the machine. And I've seen writing through an
uninitialized pointer actually cause the next call to open to
render the disk unreadable, so that it required reformatting.
And I've worked on a system where an incorrect memory write
could cause the system to telephone your boss.
One of the reasons why C and C++ stress "undefined behavior" so
much is because they are used on such a wide variety of systems.
*IF* you're running application level software on a typical
workstation or (modern) PC, then about the worse thing that can
happen is a core dump (or whatever they call it under Windows),
but C/C++ are designed for a lot of other environments as well.
And a core dump can have serious secondary effects as well.
I've worked on systems where we had contractual penalties for
down time, and the time between a core dump and the time the
program was back up and running would cost us over 10000 Euros.
(But that's a secondary effect---a classical secondary effect of
buffer overflow, for example, is to allow unknown persons to
execute arbitrary code in priviledged mode on your machine.)