https://gcc.gnu.org/g:8a2d0ea99609812c896a098b2f93298b0ca7e965
commit r17-6178-g8a2d0ea99609812c896a098b2f93298b0ca7e965 Author: Jason Merrill <[email protected]> Date: Sat Nov 7 16:11:25 2026 -0500 c++: -std=c++26 should imply -lstdc++exp When I added -fcontracts to -std=c++26 in r16-8176, I forgot to also have it imply -lstdc++exp. gcc/cp/ChangeLog: * g++spec.cc (lang_specific_driver): Also set need_experimental for C++26 and C++29. gcc/c-family/ChangeLog: * c-opts.cc (c_common_post_options): Adjust comment. Diff: --- gcc/c-family/c-opts.cc | 2 +- gcc/cp/g++spec.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index d27cf3fa6d5f..9d275e60d35e 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1261,7 +1261,7 @@ c_common_post_options (const char **pfilename) SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_range_for_ext_temps, cxx_dialect >= cxx23); - /* Contracts are in C++26. */ + /* Contracts are in C++26. Keep lang_specific_driver in sync. */ SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_contracts, cxx_dialect >= cxx26); diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc index f80432449132..6a616faaa495 100644 --- a/gcc/cp/g++spec.cc +++ b/gcc/cp/g++spec.cc @@ -166,7 +166,13 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, switch (decoded_options[i].opt_index) { + /* Contracts support requires -lstdc++exp, and c_common_post_options + enables it by default in C++26 and above. */ case OPT_fcontracts: + case OPT_std_c__26: + case OPT_std_c__29: + case OPT_std_gnu__26: + case OPT_std_gnu__29: need_experimental = true; break;
