https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116178
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Sam James from comment #8) > Build systems like autoconf currently hardcode a list of C++ and C standards > which has to be updated every so often (and often gets forgotten about). > autoconf at least will aggressively pick the latest one it knows about. We asked them to fix that, I haven't checked whether they did or not. > Obviously, it should be tested to make sure it works, but having to manually > do "what's the latest I know about vs. latest the compiler knows about" > feels cheesy. > > More so in C land, we also often see people doing things like "-std=gnu99" In general, the "not stable yet" case is much less of a problem for C. The -std option has a much smaller impact on ABI compat for C than for C++, because most C ABIs are just a symbol name anyway. For the C++ std::lib every detail of every class, inline function, and function template is an ABI artefact. > because at one point, that was new, and they don't mind using something > newer, but then they have to try balance with whatever the latest the > compiler supports. Being able to say "OK, try -std=latest-stable-std" is > useful there. But in theory that should be the default, so you don't need it. If you use C17 features and the default -std option is C11, then relying on the default doesn't work, but neither does -std=latest-stable (because that should be the same as the default). So you really need "latest unstable" ... and then you're doing something which possibly shouldn't be put into distro builds anyway (for C++, less so for C). Better yet, Autoconf has a AC_PROG_CXX_STDCXX_EDITION_TRY which can be used to say "I need C++17, add the relevant option if required but don't add it if the default already meets that". So if the default is already C++17, or is even newer, then it doesn't add any -std option. That way you don't get -std=c++17 still hardcoded in 10 years when it's no longer needed, because every compiler defaults to something newer anyway. The cmake equivalent is target_compile_features(mylib PUBLIC cxx_std_11) https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html#requiring-language-standards "clients must use a compiler mode that is no less than C++ 11" > I think it's also likely to be useful in CI as people may not realise when > their compiler starts to support a new standard (they may already know it > exists and such but it's not yet in their Ubuntu image or whatever). Yup, that makes sense. "Run tests using the latest -std mode to check for incompatibilities, we don't care if it's stable or experimental because this is CI not builds we plan to keep or distribute". Calling it -std=c++-unstable-no-warranty-given-or-implied works fine for that case, but -std=c++latest-stable doesn't help (because again, it should be the default -std anyway).