On Wednesday, 13 July 2016 at 13:52:06 UTC, Chris Wright wrote:
Undefined stuff *can* make sense. I want to mutate a data
structure marked immutable. It's obvious what I want to have
happen, it's just not obvious what will actually happen.
But the compiler is part of the abstract machine so it could
simply refuse to compile a program that isn't valid, or it could
define an extension that makes more programs valid.
One usually use the these terms:
«well-formed program»: a program that follows both the
syntactical rules and the required statically-detected semantic
rules.
«valid program»: a program that is well-formed and that also does
not lead to semantic errors that are required to be detected at
least at runtime (or in the case of undefined behaviour; errors
that are not required to be detected for performance reasons).
Since C/C++ is aiming at avoiding semantic run-time checks the
standard go with undefined behaviour instead. But there are
compilers that do more than that.