C++26 is done (again): ISO C++ meeting trip report
C++26’s revived “contracts” feature has become a flashpoint over the language’s priorities, pitting those who see it as a step toward safer, more robust APIs against critics who argue it’s overcomplicated, weak on true memory safety, and being rushed through a flawed standards process. Many compare C++ unfavorably to Rust on guarantees like borrow checking and package management, while others insist C++ should lean into its existing strengths—performance, ecosystem, and extensibility—rather than trying to copy Rust’s model. Underneath the technical debate is broader frustration with WG21’s governance, perceived feature bloat, and the burden new standard library additions place on already stretched implementers.
Contracts in C++26
- Central debate is over the new contracts feature and whether it belongs in C++26 at all.
- Original design allowed compilers to turn off contract checks and still be conforming; many see this as undermining any safety benefits.
- Recent change adds a way to mark specific contracts as “always enforced” (e.g.,
pre<enforced>(...)), so library authors can guarantee certain checks run regardless of build flags. - Critics find the syntax clunky, fear “malicious compliance” from implementers, and argue it’s still functionally similar to existing assertions.
- Some argue contracts are useful for expressing pre/postconditions (bounds, non-null, invariants); others say that without static guarantees, they are just optional debugging aids.
Memory Safety and Type Semantics
- Strong disagreement on whether contracts meaningfully improve memory safety:
- Proponents: contracts plus hardened implementations and bounds-checked APIs can make C++ applications safer.
- Opponents: they don’t address core issues like lifetimes, use-after-free, iterator invalidation, or enforcing safe APIs.
- Discussion of using richer types (e.g., Ada-style integer subranges) and non-null references as safer alternatives to raw pointers, but with caveats about UB, compiler optimizations, and legacy patterns.
C++ vs. Rust and Language Goals
- Thread contrasts Rust’s enforced safety (borrow checker,
unsafeboundaries) with C++’s culture of optional checks and performance-first mindset. - Some see C++’s type system and metaprogramming as more powerful; others think Rust’s guarantees and tooling make it strictly preferable for new projects.
- Several argue C++ shouldn’t try to “beat Rust at Rust’s game,” but remain “C with extra features,” embracing opt-in tools rather than hard guarantees.
Packaging and Ecosystem
- Some claim the committee is neglecting critical areas like packaging and memory safety in favor of niche features.
- Others insist packaging is an ecosystem concern, not a language one, and point to existing tools (Conan, vcpkg, CPS) while noting contributor burnout on standardizing packaging.
Committee Process and Other Changes
- Multiple comments describe WG21 as dysfunctional, overly fragmented, and prone to piling on library features that implementers struggle to maintain.
- Contracts’ narrow approval margins and repeated NB friction are seen by some as a “worst possible outcome” and a political showdown.
- Smaller changes: labeled
break/continueare welcomed as overdue; deprecating0-prefixed octal literals is seen as potentially noisy churn, mostly affecting permission-related code.