Lightning Talk: The UB Detector: constexpr
summary
Claim that a constexpr evaluation forbids undefined behaviour is false: C++20 code using std::views::filter, mutating elements so they no longer satisfy the predicate, triggers UB at compile time and yields a surprising odd value where evens were expected. more than zero undefined behaviours. Compiler Explorer: clang and gcc agree and a compile-time static_assert fails with odd value 5. A second example shows a [[noreturn]] function returning a value is UB yet compilers sometimes accept it.
AI-written summary · about
related talks
33mUndefined Behavior in C++: What Every Programmer Should Know and Fear
01h 02mBack To Basics: Undefined Behavior
01h 04mHarnessing constexpr: a path to safer C++
01h 04mRemoving Needless Undefined Behavior for a Safer C++
01h 04mUndefined Behavior in the STL
01h 30mDangerous Optimizations in C and C++ Programming Languages
01h 02mPractical Tips for Safer C++
03mUndefined Behavior - Not what you expected
