SATURDAY, NOVEMBER 7, 2026
c++
C++26 and C++29 imply experimental library support.
` -std=c++26` and `-std=c++29` now imply `-lstdc++exp`.
This commit updates the C++ driver options so that specifying C++26 or C++29 language standards will now automatically imply the use of the experimental C++ library (-lstdc++exp). This change ensures that features related to contracts, which were previously added for C++26, are correctly enabled alongside the language standard.
In Details
In gcc/cp/g++spec.cc, the lang_specific_driver function is modified to set need_experimental for both C++26 and C++29 language standards. This complements the earlier addition of -fcontracts to -std=c++26 (r16-8176), ensuring that the experimental C++ library components are implicitly linked when these newer standards are selected.
For Context
- C++26
- A future standard of the C++ programming language, expected to include new features and library components beyond C++23.
- C++29
- A future standard of the C++ programming language, following C++26.
- imply
- In the context of compiler flags, 'imply' means that selecting one option automatically enables another related option without the user explicitly specifying it.
- -lstdc++exp
- A linker flag that instructs the compiler to link against the experimental C++ standard library. This library contains features that are under development or have not yet been fully standardized.
- contracts
- A C++20 feature (and further developed in later standards) that allows programmers to specify preconditions, postconditions, and assertions for functions and code blocks. These help in verifying program correctness and documenting expected behavior.