Harnessing constexpr: a path to safer C++
summary
Claims that using constexpr from C++11 through C++26 reduces UB and memory bugs, backed by examples where compilers reject integer overflow and dangling string_view, and by sanitizers (ASan/UBSan) and static analysis comparisons; cites Microsoft and Google figures (~70% and ~67% of vulnerabilities tied to memory safety). Demonstrations build compile‑time tests with Catch2/static_assert, fmt and a consteval two‑step trick to produce diagnostics; constexpr detection works when the failing path is exercised but requires good test coverage, exposes missing constexpr in libraries, cannot replace runtime sanitizers for IO or threads.
AI-written summary · about
chapters (8)
- 0:00Introduction and agenda
- 1:21Is C++ a safe language?
- 4:55Common pitfalls in C++
- 13:35Traditional solutions
- 20:45Evolution of constexpr
- 35:15Constexpr in C++26
- 40:41Constexpr case studies
- 48:18Testing constexpr code
related talks
01h 13mPractical Tips for Safer C++
33mUndefined Behavior in C++: What Every Programmer Should Know and Fear
01h 02mPractical Tips for Safer C++
01h 26mVulnerable C++
50mSecure development with C++ - Lessons and techniques
07mLightning Talk: The UB Detector: constexpr
01h 30mDangerous Optimizations in C and C++ Programming Languages
01h 26mA Path to Practically Safe C++
