The Dawn of a New Error, (C++ error-handling and exceptions)
summary
Proposal p0709 implements zero-overhead deterministic exceptions by turning throws into a return-channel value isomorphic to std::expected plus a lightweight std::error status_code (p1028) that fits in two registers and removes the boolean/string and singleton problems. Supporting papers add a move_relocates attribute and object-relocation to let erasure be memcpyable, enabling optimizer-level discriminators and near‑no‑cost propagation. Compiler can statically check frozen functions and an optional try keyword enables interop with dynamic exceptions; boost::outcome is a usable library prototype today.
AI-written summary · about
chapters (28)
- 0:00Introduction and welcome
- 1:58Historical context of error handling
- 3:46Exploding return types and early ideas
- 6:33Expected and Result types in languages
- 8:43Using std::expected for error handling
- 11:36Boilerplate and pain points
- 13:00Monadic operations for expected
- 14:49Exceptions vs. expected performance
- 15:53Static exceptions with p0709
- 19:46Introducing std::error
- 21:50System error code limitations
- 28:53Proposed std::status_code changes
- 33:54Move relocate and object relocation
- 37:08Summary of proposals
- 40:01Q&A: Pointer usage and overhead
- 41:50Q&A: Syntax similarity to dynamic exceptions
- 42:31Q&A: Zero-cost abstraction claims
- 43:35Q&A: Local error handling
- 45:02Q&A: Domain overhead and RTTI
- 46:28Q&A: Error type specification
- 48:16Q&A: Transitioning from exceptions
- 49:47Q&A: Optional try keyword enforcement
- 50:52Q&A: Recommendations for current code
- 52:18Q&A: Type erasure and catching
- 54:07Q&A: Future of exception hierarchies
- 55:35Q&A: Getting p0709 into C++23
- 56:37Q&A: Optional try keyword necessity
- 57:18Q&A: Breaking std::exception inheritance
related talks
01h 47mFunctional C++
01h 39m“Thoughts on a more powerful and simpler C++ (5 of N)”
54mUndefined Behaviour is awesome!
46m“My Little Optimizer: Undefined Behavior is Magic"
27mDesigning interrupts for ML and OCaml
01h 41mC++ Type Erasure Demystified
01h 03mC++ Trivial Relocation Through Time
50mExpression Templates: Past, Present, Future
