]> git.feebdaed.xyz Git - 0xmirror/gcc.git/commit
Change the default C++ dialect to gnu++20
authorJakub Jelinek <jakub@redhat.com>
Wed, 26 Nov 2025 14:01:11 +0000 (15:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 26 Nov 2025 14:01:11 +0000 (15:01 +0100)
commit004438857554f47eb5491d59b067e56fdacf0e74
tree84533cf195509d970a19b051081689f065487b83
parent4e7213aa081f1c0ca5b7e6a60d4e7ba5bcfb1f8a
Change the default C++ dialect to gnu++20

On Mon, Nov 03, 2025 at 01:34:28PM -0500, Marek Polacek via Gcc wrote:
> I would like us to declare that C++20 is no longer experimental and
> change the default dialect to gnu++20.  Last time we changed the default
> was over 5 years ago in GCC 11:
> <https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=0801f419440c14f6772b28f763ad7d40f7f7a580>
> and before that in 2015 in GCC 6.1, so this happens roughly every 5 years.
>
> I had been hoping to move to C++20 in GCC 15 (see bug 113920), but at that time
> libstdc++ still had incomplete C++20 support and the compiler had issues to iron
> out (mangling of concepts, modules work, etc.).  Are we ready now?  Is anyone
> aware of any blockers?  Presumably we still wouldn't enable Modules by default.
>
> I'm willing to do the work if we decide that it's time to switch the default
> C++ dialect (that includes updating cxx-status.html and adding a new caveat to
> changes.html).

I haven't seen a patch posted for this, so just that something is posted
during stage1 if we decide to do it, here is a patch.

The patch makes -std=gnu++20 the default C++ dialect and documents that
-fmodules is still not implied by that or -std=c++20 and modules support
is still experimental.

2025-11-26  Jakub Jelinek  <jakub@redhat.com>

gcc/
* doc/invoke.texi (gnu++17): Remove comment about the default.
(c++20): Remove note about experimental support, except add a note
that modules are still experimental and need to be enabled separately.
(gnu++20): Likewise.  Move here comment about the default.
(fcoroutines): Mention it is enabled by default for C++20 and later.
* doc/standards.texi: Document that the default for C++ is
-std=gnu++20.
gcc/c-family/
* c-opts.cc (c_common_init_options): Call set_std_cxx20 rather than
set_std_cxx17.
* c.opt (std=c++2a): Change description to deprecated option wording.
(std=c++20): Remove experimental support part.
(std=c++2b): Change description to deprecated option wording.
(std=gnu++2a): Likewise.
(std=gnu++20): Remove experimental support part.
(std=gnu++2b): Change description to deprecated option wording.
gcc/testsuite/
* lib/target-supports.exp: Set cxx_default to c++20 rather than
c++17.
* lib/g++-dg.exp (g++-std-flags): Reorder list to put 20 first
and 17 after 26.
* g++.dg/debug/pr80461.C (bar): Use v = v + 1; instead of ++v;.
* g++.dg/debug/pr94459.C: Add -std=gnu++17 to dg-options.
* g++.dg/diagnostic/virtual-constexpr.C: Remove dg-skip-if,
instead use { c++11 && c++17_down } effective target instead of
c++11.
* g++.dg/guality/pr67192.C: Add -std=gnu++17.
* g++.dg/torture/pr84961-1.C: Likewise.
* g++.dg/torture/pr84961-2.C: Likewise.
* g++.dg/torture/pr51482.C (anim_track_bez_wvect::tangent): Cast
key_class to int before multiplying it by float.
* g++.dg/torture/stackalign/unwind-4.C (foo): Use g_a = g_a + 1;
instead of g_a++;.
* g++.dg/tree-prof/partition1.C (bar): Use l = l + 1; return l;
instead of return ++l;.
* obj-c++.dg/exceptions-3.mm: Add -std=gnu++17.
* obj-c++.dg/exceptions-5.mm: Likewise.
libgomp/
* testsuite/libgomp.c++/atomic-12.C (main): Add ()s around array
reference index.
* testsuite/libgomp.c++/atomic-13.C: Likewise.
* testsuite/libgomp.c++/atomic-8.C: Likewise.
* testsuite/libgomp.c++/atomic-9.C: Likewise.
* testsuite/libgomp.c++/loop-6.C: Use count = count + 1;
return count > 0; instead of return ++count > 0;.
* testsuite/libgomp.c++/pr38650.C: Add -std=gnu++17.
* testsuite/libgomp.c++/target-lambda-1.C (merge_data_func):
Use [=,this] instead of just [=] in lambda captures.
* testsuite/libgomp.c-c++-common/target-40.c (f1): Use v += 1;
instead of v++;.
* testsuite/libgomp.c-c++-common/depend-iterator-2.c: Use v = v + 1;
instead of v++.
26 files changed:
gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/doc/invoke.texi
gcc/doc/standards.texi
gcc/testsuite/g++.dg/debug/pr80461.C
gcc/testsuite/g++.dg/debug/pr94459.C
gcc/testsuite/g++.dg/diagnostic/virtual-constexpr.C
gcc/testsuite/g++.dg/guality/pr67192.C
gcc/testsuite/g++.dg/torture/pr51482.C
gcc/testsuite/g++.dg/torture/pr84961-1.C
gcc/testsuite/g++.dg/torture/pr84961-2.C
gcc/testsuite/g++.dg/torture/stackalign/unwind-4.C
gcc/testsuite/g++.dg/tree-prof/partition1.C
gcc/testsuite/lib/g++-dg.exp
gcc/testsuite/lib/target-supports.exp
gcc/testsuite/obj-c++.dg/exceptions-3.mm
gcc/testsuite/obj-c++.dg/exceptions-5.mm
libgomp/testsuite/libgomp.c++/atomic-12.C
libgomp/testsuite/libgomp.c++/atomic-13.C
libgomp/testsuite/libgomp.c++/atomic-8.C
libgomp/testsuite/libgomp.c++/atomic-9.C
libgomp/testsuite/libgomp.c++/loop-6.C
libgomp/testsuite/libgomp.c++/pr38650.C
libgomp/testsuite/libgomp.c++/target-lambda-1.C
libgomp/testsuite/libgomp.c-c++-common/depend-iterator-2.c
libgomp/testsuite/libgomp.c-c++-common/target-40.c