The Difference Between Undefined Behavior and Ill-formed C++ Programs -- Raymond Chen
The C++ language has two large categories of “don’t do that” known as undefined behavior and ill-formed program. What’s the difference?
The Difference Between Undefined Behavior and Ill-formed C++ Programs
by Raymond Chen
From the article:
The C++ language has two large categories of “don’t do that” known as undefined behavior and ill-formed program. What’s the difference?
Undefined behavior (commonly abbreviated UB) is a runtime concept. If a program does something which the language specified as “a program isn’t allowed to do that”, then the behavior at runtime is undefined: The program is permitted by the standard to do anything it wants. Furthermore, the effect of undefined behavior can go backward in time and invalidate operations that occurred prior to the undefined behavior. It can do things like execute dead code. However, if your program avoids the code paths which trigger undefined behavior, then you are safe.