Undefined Behavior is Not an Error
summary
Core claim: undefined behavior is not an error — the compiler may legally treat UB as “code not present,” leading to surprising results. Real examples: a missing return jumps into the next function, an out‑of‑bounds operator[] lets an optimizer remove loop bodies (output becomes empty), and signed integer overflow lets clang replace a loop with a multiply/divide. Fixes: rewrite code or use safer patterns (version 3 used compile‑time counter, constexpr and recursive templates and avoids UB). Tools: sanitizers, Coverity, clang static analyzer, valgrind, godbolt and multiple compilers/flags.
AI-written summary · about
chapters (13)
- 0:00Start
- 2:15Why Are We Giving this Talk
- 6:21Defined Behavior
- 10:13What Is Undefined Behavior
- 12:55Why Are We Studying Undefined Behavior
- 15:23Compile Time Counter
- 28:59Audience-Participation
- 35:48Quiz Time
- 37:01Order of Evaluation of Operands
- 41:07Undocumented Behavior
- 45:19To Treat Undefined Behavior as a Critical Bug
- 45:49Static Analysis Tools
- 48:47Recap
related talks
49mUndefined Behavior in 2017 (part 1 of 2)
01h 04mRemoving Needless Undefined Behavior for a Safer C++
05mDetecting Programs That Rely on Undefined Behavior
01h 30mDangerous Optimizations in C and C++ Programming Languages
26mUndefined Behavior in 2017 (part 2 of 2)
19mLightning Talk: Your Favorite Undefined Behavior in C++
01h 27mDangerous Optimizations! in C++ - Part Deux
03mLightning Talk: Undefined Behaviour in C++
