Undefined Behavior¶
A programming-language case for which the governing specification imposes no requirements on implementation behavior.
Core Idea¶
Undefined behavior is a case for which a programming-language specification imposes no requirements on an implementation. Under the cited C++ working draft, an execution that triggers such a condition has no standard-mandated result for that case. A compiler can optimize defined executions on the assumption that those conditions are avoided.[ref-cea316ed7f5b][ref-70deb5df5b0b]
Scope of Application¶
The exact boundary depends on the language and version. The C++ draft classifies an unrepresentable signed arithmetic result and a shift count outside the allowed range as UB. It separately defines unspecified, implementation-defined and erroneous behavior. Processor “UNPREDICTABLE” language and LLVM IR poison have their own rules, not automatic aliases.[ref-cea316ed7f5b-4][ref-cea316ed7f5b-5][^ref-cea316ed7f5b-3]
Clarity¶
“Undefined” is not merely a result the programmer does not know. Unspecified behavior is bounded by allowed outcomes; implementation-defined behavior must be documented; recent C++ erroneous behavior is well-defined but recommended to diagnose. UB is the no-requirements category.[ref-cea316ed7f5b][ref-cea316ed7f5b-2][^ref-cea316ed7f5b-3]
Manages Complexity¶
The category marks cases a standard does not constrain, allowing compiler assumptions for defined executions. That shifts prevention onto program authors and tools; a sanitizer can detect selected reached cases but does not itself define the language rule.[ref-70deb5df5b0b][ref-21d8517fea28]
Abstract Reasoning¶
Name the standard version and clause, determine whether a specific execution reaches its undefined condition, and avoid inferring portable behavior from one observed run. The latest C++ draft has more precise defined-prefix wording than the blanket slogan that absolutely nothing before a UB event can be constrained.[^ref-cea316ed7f5b-2]
Knowledge Transfer¶
The contract question transfers across languages and intermediate representations, but the classifications and consequences must be rechecked per specification. Erroneous Program is a separate identity-review hold, not a UB alias; the generic missing-guarantee skeleton does not by itself make this a prime.
[^ref-cea316ed7f5b]: C++ standards draft editors, “C++ Working Draft Eelis Snapshot c7015b485cc3db8efaa9dfb9ff0809c5394a4ed1”, unofficial eel.is HTML rendering of “Working Draft: Programming Languages — C++” generated 2026-08-23, [defns.undefined] definition; not an ISO publication.
[^ref-cea316ed7f5b-2]: C++ standards draft editors, “C++ Working Draft Eelis Snapshot c7015b485cc3db8efaa9dfb9ff0809c5394a4ed1”, unofficial eel.is HTML rendering of “Working Draft: Programming Languages — C++” generated 2026-08-23, [intro.abstract] distinctions and defined-prefix wording; not an ISO publication.
[^ref-cea316ed7f5b-3]: C++ standards draft editors, “C++ Working Draft Eelis Snapshot c7015b485cc3db8efaa9dfb9ff0809c5394a4ed1”, unofficial eel.is HTML rendering of “Working Draft: Programming Languages — C++” generated 2026-08-23, [defns.erroneous] definition; not an ISO publication.
[^ref-cea316ed7f5b-4]: C++ standards draft editors, “C++ Working Draft Eelis Snapshot c7015b485cc3db8efaa9dfb9ff0809c5394a4ed1”, unofficial eel.is HTML rendering of “Working Draft: Programming Languages — C++” generated 2026-08-23, [expr.pre] arithmetic rule; not an ISO publication.
[^ref-cea316ed7f5b-5]: C++ standards draft editors, “C++ Working Draft Eelis Snapshot c7015b485cc3db8efaa9dfb9ff0809c5394a4ed1”, unofficial eel.is HTML rendering of “Working Draft: Programming Languages — C++” generated 2026-08-23, [expr.shift] shift-count rule; not an ISO publication.
[^ref-70deb5df5b0b]: LLVM compiler author's UB explanation.
[^ref-21d8517fea28]: Clang UndefinedBehaviorSanitizer documentation.
Neighborhood in Abstraction Space¶
Undefined Behavior sits in a sparse region of the domain-specific corpus (88th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Program Scope & Nesting Disciplines (10 abstractions)
Nearest neighbors
- Proof of correctness — 0.83
- Proof-Carrying Code — 0.81
- Closure (programming) — 0.80
- Principle of Explosion — 0.80
- Contingent Contract — 0.79
Computed from structural-signature embeddings · 2026-10-08