-
Book Overview & Buying
-
Table Of Contents
C++ Memory Management
By :
Undefined behavior, often abbreviated to UB, results from a situation in which the standard does not prescribe a specific behavior. In the C++ standard, UB is behavior for which no requirements are imposed. It can lead to the problem being ignored, just as it can lead to a diagnostic or program termination. The key idea is that if your program has undefined behavior, then it’s not playing by the rules of the language and is broken; its behavior is not guaranteed on your platform, it’s not portable between platforms or compilers, and it cannot be relied upon.
A correctly written C++ program has no undefined behavior. When faced with a function that contains undefined behavior, the compiler can do just about anything with the code in that function, which makes reasoning from source code essentially impossible.
Undefined behavior is one of the preeminent “things to be careful with” listed in Chapter 2. Strive to avoid undefined behavior...