Rainer said:
Too many people cannot get their heads around the idea that
'undefined' implies 'nobody knows anything about it'
Good - because that's not what it means. It means "the C standard
provides no guarantees". Another standard, such as POSIX, or a
standard ABI for a given platform, or even the implementation itself,
may provide guarantees that the C standard does not, and there might
be a very large number of people who know about those guarantees.
Even if there are no official guarantees from any source, it's
entirely possible that there's at least one person (and probably a
large number of persons) who knows what any particular implementation
will actually do wth a particular kind of code construct with
undefined behavior - at the very least, I would certainly hope that
whoever actually designed the relevant part of that implementation
would have some idea what it actually does - if not, I wouldn't
recommend relying upon that implementation.
... and not 'program
will crash' and too many other people try to reinforce this notion by
wandering off into long strains of phantastic speculation.
The fantastic speculation serves mainly to draw people's attention to
the important point: the lack of constraints imposed by the C standard
when the behavior is defined. That there are other constraints that
might apply is also an important point, but it can be discussed after
you get their attention; it's a fact that doesn't lend itself as
readily to serving as an attention-getting device. There might be
other reasons why nasal demons are not a possibility, even when the
code has undefined behavior, but it is perfectly accurate to point out
that constraints imposed by the C standard are NOT among those
reasons.
Nonetheless, such mechanisms do exist (I've already mentioned them in
vague terms that should have been sufficiently specific for your
imagination to fill in the details). They are in use, and compilers
using them are conforming, and it's important for developers to be
aware of that fact if they care about the portability of their code.
It's not very important if they're sure they'll never use a compiler
using such aggressive optimization techniques.