Undefined Behavior
A semantic category in the ISO C standard that permits a compiler to handle certain code in arbitrary ways, including producing seemingly correct output, crashing, silently corrupting data, or deleting the relevant code. Common cases include signed integer overflow, array out-of-bounds access, and null pointer dereference.
Timeline (last 90 days)
Undefined behavior (UB) in the C standard allows an implementation to do anything when it encounters that behavior, including producing seemingly correct output, crashing, silently corrupting data, or deleting the relevant code entirely after optimization.
Signed integer overflow, out-of-bounds array reads and writes, dereferencing null or dangling pointers, violating sequence point rules, and reading uninitialized variables are all explicitly listed by the C standard as undefined behavior.
The compiler assumes that signed addition never overflows, thereby concluding that certain boundary conditions are unreachable and deleting the corresponding check branches, which is extremely common at -O2 and above.
In Rust, soundness means: if the compiler accepts a piece of code, but that code may trigger undefined behavior at runtime, then the compiler is unsound.
Undefined behavior (UB) refers to operations for which the language specification explicitly does not guarantee any behavior, such as dereferencing a dangling pointer, data races, out-of-bounds access, etc.
Rust's design goal is to statically eliminate the vast majority of undefined behavior at compile time through ownership and borrowing rules.
All Facts (6)
Undefined behavior (UB) in the C standard allows an implementation to do anything when it encounters that behavior, including producing seemingly correct output, crashing, silently corrupting data, or deleting the relevant code entirely after optimization.
50%UnverifiedSigned integer overflow, out-of-bounds array reads and writes, dereferencing null or dangling pointers, violating sequence point rules, and reading uninitialized variables are all explicitly listed by the C standard as undefined behavior.
50%UnverifiedThe compiler assumes that signed addition never overflows, thereby concluding that certain boundary conditions are unreachable and deleting the corresponding check branches, which is extremely common at -O2 and above.
50%UnverifiedIn Rust, soundness means: if the compiler accepts a piece of code, but that code may trigger undefined behavior at runtime, then the compiler is unsound.
50%UnverifiedUndefined behavior (UB) refers to operations for which the language specification explicitly does not guarantee any behavior, such as dereferencing a dangling pointer, data races, out-of-bounds access, etc.
50%UnverifiedRust's design goal is to statically eliminate the vast majority of undefined behavior at compile time through ownership and borrowing rules.
50%