Removing Needless Undefined Behavior for a Safer C++
summary
C++ has many specific undefined behaviors (UB) that can be classified and constrained rather than left unconstrained; examples include null-dereference/time-travel optimizations that once let GCC turn a null call into running rogue then removing files, preprocessor tokenization quirks that Microsoft later diagnosed, and uninitialized local reads that enable hijacks. Proposed fixes for C++26 include making some preprocessor cases ill-formed no diagnostic required, adding a contracts facility to check preconditions at runtime, experimenting with zero-initialize locals, and relying on tooling like UBSan/ASan/TSAN for detection.
AI-written summary · about
chapters (30)
- 0:00Introduction
- 0:20Who am I
- 1:12Outline
- 2:00Why this talk
- 4:10Show Hands
- 4:20Popular Quotes
- 5:32Time Travel
- 8:10Program Definition
- 10:24Compile Time
- 11:18Compile Time Behavior
- 18:14Can we time travel
- 19:00Time travel example
- 19:30Simple example
- 22:45Testing the example
- 25:30Thesis
- 26:17Social Contract
- 27:49Possible fixes
- 29:25Examples
- 30:50Preprocessor
- 34:08Local Variables
- 37:13Welldefined Behavior
- 41:00Jake Fevold
- 44:58What is erroneous behavior
- 46:24A quick drink
- 46:46Preconditional callout
- 47:25Preconditional examples
- 49:43Why support this
- 50:58C26 Contracts
- 54:18Contract Violation
- 57:28Example
related talks
49mUndefined Behavior in 2017 (part 1 of 2)
33mUndefined Behavior in C++: What Every Programmer Should Know and Fear
01h 30mDangerous Optimizations in C and C++ Programming Languages
05mDetecting Programs That Rely on Undefined Behavior
26mUndefined Behavior in 2017 (part 2 of 2)
01h 02mBack To Basics: Undefined Behavior
57mUndefined Behavior is Not an Error
01h 04mUndefined Behavior in the STL
