]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
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

index 1e0f0c59ade0ab846d202b49d156884d184ed33b..8da51759dfd33c55ee57b3748352a07c48e83c4a 100644 (file)
@@ -274,9 +274,9 @@ c_common_init_options (unsigned int decoded_options_count,
          }
     }
 
-  /* Set C++ standard to C++17 if not specified on the command line.  */
+  /* Set C++ standard to C++20 if not specified on the command line.  */
   if (c_dialect_cxx ())
-    set_std_cxx17 (/*ISO*/false);
+    set_std_cxx20 (/*ISO*/false);
 
   global_dc->get_source_printing_options ().colorize_source_p = true;
 }
index 8da089780c4e8b0fbacc58b2487d1c870902e7a8..e1576c9c3c37737221ab8a03407f741bf6e5d4ee 100644 (file)
@@ -2618,15 +2618,15 @@ Conform to the ISO 2017 C++ standard.
 
 std=c++2a
 C++ ObjC++ Alias(std=c++20) Undocumented
-Conform to the ISO 2020 C++ standard (experimental and incomplete support).
+Deprecated in favor of -std=c++20.
 
 std=c++20
 C++ ObjC++
-Conform to the ISO 2020 C++ standard (experimental and incomplete support).
+Conform to the ISO 2020 C++ standard.
 
 std=c++2b
 C++ ObjC++ Alias(std=c++23) Undocumented
-Conform to the ISO 2023 C++ standard (published in 2024; experimental and incomplete support).
+Deprecated in favor of -std=c++23.
 
 std=c++23
 C++ ObjC++
@@ -2720,15 +2720,15 @@ Conform to the ISO 2017 C++ standard with GNU extensions.
 
 std=gnu++2a
 C++ ObjC++ Alias(std=gnu++20) Undocumented
-Conform to the ISO 2020 C++ standard with GNU extensions (experimental and incomplete support).
+Deprecated in favor of -std=gnu++20.
 
 std=gnu++20
 C++ ObjC++
-Conform to the ISO 2020 C++ standard with GNU extensions (experimental and incomplete support).
+Conform to the ISO 2020 C++ standard with GNU extensions.
 
 std=gnu++2b
 C++ ObjC++ Alias(std=gnu++23) Undocumented
-Conform to the ISO 2023 C++ standard with GNU extensions (published in 2024; experimental and incomplete support).
+Deprecated in favor of -std=gnu++23.
 
 std=gnu++23
 C++ ObjC++
index 06723c2b3b6236290d9d3535a46b261eee515f1e..45317666bc7e05bc461300f90308cdb3aa526fb7 100644 (file)
@@ -2627,21 +2627,21 @@ The name @samp{c++1z} is deprecated.
 @item gnu++17
 @itemx gnu++1z
 GNU dialect of @option{-std=c++17}.
-This is the default for C++ code.
 The name @samp{gnu++1z} is deprecated.
 
 @item c++20
 @itemx c++2a
 The 2020 ISO C++ standard plus amendments.
-Support is experimental, and could change in incompatible ways in
-future releases.
+C++20 modules support is still experimental and needs to be
+enabled with @option{-fmodules} option.
 The name @samp{c++2a} is deprecated.
 
 @item gnu++20
 @itemx gnu++2a
 GNU dialect of @option{-std=c++20}.
-Support is experimental, and could change in incompatible ways in
-future releases.
+This is the default for C++ code.
+C++20 modules support is still experimental and needs to be
+enabled with @option{-fmodules} option.
 The name @samp{gnu++2a} is deprecated.
 
 @item c++23
@@ -3398,7 +3398,9 @@ called.  If the handler returns, execution continues normally.
 
 @opindex fcoroutines
 @item -fcoroutines
-Enable support for the C++ coroutines extension (experimental).
+Enable support for the C++ coroutines extension.  With @option{-std=c++20}
+and above, coroutines are part of the language standard, so
+@option{-fcoroutines} defaults to on.
 
 @opindex fdiagnostics-all-candidates
 @item -fdiagnostics-all-candidates
index c7c6f28ee21860ddba7dfcdbe648868bef6ac864..2c2063a750a9ea01e0ed2587ccb8f68561c3a968 100644 (file)
@@ -289,7 +289,7 @@ select an extended version of the C++ language explicitly with
 @option{-std=gnu++23} (for C++23 with GNU extensions).
 
 The default, if
-no C++ language dialect options are given, is @option{-std=gnu++17}.
+no C++ language dialect options are given, is @option{-std=gnu++20}.
 
 @section Objective-C and Objective-C++ Languages
 @cindex Objective-C
index b472e62c8037ddc34674627031ffe19c2fd92c82..440241da5e8b0e424f5733cb979a96e8ca2908d2 100644 (file)
@@ -30,7 +30,7 @@ bar ()
 {
   O q;
   A<P> f = q;
-  v++;
+  v = v + 1;
 }
 
 void
index ebc0cf45cc6466f37e6c0e8b92f8f0db261ddfa3..6886bdb6e438d0c8ee2a927d483c5ed3a8445721 100644 (file)
@@ -1,6 +1,6 @@
 // PR debug/94459
 // { dg-do compile { target c++14 } }
-// { dg-options "-g -dA" }
+// { dg-options "-g -dA -std=gnu++17" }
 
 template <typename T>
 struct S
index 9223c6927376ce6a74f5a7cf31c943d23348f69f..1daa86dd902f9fcdd959022914237b1975416b98 100644 (file)
@@ -1,6 +1,5 @@
 // { dg-options "-fdiagnostics-show-caret -pedantic-errors" }
-// { dg-do compile { target c++11 } }
-// { dg-skip-if "virtual constexpr" { *-*-* } { "-std=gnu++2a" } { "" } }
+// { dg-do compile { target { c++11 && c++17_down } } }
 
 struct S
 {
index c09ecf8dc817a69e8b7c5252a09bc224367dfd72..9c30dd7ca9d27a4df7ee2eac2895d52038e12fd7 100644 (file)
@@ -1,6 +1,6 @@
 /* PR debug/67192 */
 /* { dg-do run } */
-/* { dg-options "-x c++ -g -Wmisleading-indentation" } */
+/* { dg-options "-x c++ -g -Wmisleading-indentation -std=gnu++17" } */
 
 volatile int cnt = 0;
 
index 4032703f7208c4e66fa657e729e493be42aa2837..d4d6ae45d1f59f17bc762328b0f4f45f517d17dd 100644 (file)
@@ -22,7 +22,7 @@ WVECT * anim_track_bez_wvect::tangent(int kn, BEZIER_KEY_CLASS key_class, WVECT
   g1.y = (p_p1->y - p_p0->y)*bp1;
   g1.z = (p_p1->z - p_p0->z)*bp1;
   g1.w = (p_p1->w - p_p0->w)*bp1;
-  bp1 = (0.5f + key_class*0.5f*continuity);
+  bp1 = (0.5f + ((int)key_class)*0.5f*continuity);
   p_tn->x = (g1.x + g3.x*bp1)*tn1;
   p_tn->y = (g1.y + g3.y*bp1)*tn1;
   p_tn->z = (g1.z + g3.z*bp1)*tn1;
index 6a72ad5134fc30cdd0930f0af7027a6ce808d24b..2c372c5e31e5c9fea08243ce3768233287221ea4 100644 (file)
@@ -1,5 +1,6 @@
 // PR c++/84961
 // { dg-do compile }
+// { dg-options "-std=gnu++17" }
 
 short a;
 volatile int b;
index 0909eedb7f964e8167a292ffa45f36acf6332663..7f4fe69d103f6f24bfcd1e999815a56732616e14 100644 (file)
@@ -1,5 +1,6 @@
 // PR c++/84961
 // { dg-do compile }
+// { dg-options "-std=gnu++17" }
 
 short a;
 volatile int b;
index fddf27625705c083b5f0426219986025d7784a37..6b9339e7e7ff2822f2fac1a1a2cb25fcf210b65f 100644 (file)
@@ -11,7 +11,7 @@ foo()
        int i;
        ALTER_REGS();
        for (i=0; i < 10; i++)
-               g_a++;
+               g_a = g_a + 1;
        throw g_a;
 }
 #endif
index 8dd64aa27a51ab2b3781d48567c55c792403d091..b3095bd6a5083813fa7e11551a0c20248432cd94 100644 (file)
@@ -16,7 +16,8 @@ int bar (int i)
   void *p = __builtin_alloca (i);
   asm volatile ("" : : "r" (i), "r" (p) : "memory");
   if (k) throw 6;
-  return ++l;
+  l = l + 1;
+  return l;
 }
 
 void foo ()
index 042a9171c7563d09e02f4ab5af2102812c251c23..abecd8877c308615c5e668b09be2c1b08123c00d 100644 (file)
@@ -78,7 +78,7 @@ proc g++-std-flags { test } {
            # The order of this list is significant: first $cxx_default,
            # then the oldest and newest, then others in rough order of
            # importance based on test coverage and usage.
-           foreach ver { 17 98 26 11 20 14 23 } {
+           foreach ver { 20 98 26 17 11 14 23 } {
                set cmpver $ver
                if { $ver == 98 } { set cmpver 03 }
                if { [llength $std_list] < 3
index c0b8026f8e72144bc618692609aa17abdab9e1e9..1df80d412da7d83c7d526ee2f0e9a5bd1e4bd492 100644 (file)
@@ -12158,7 +12158,7 @@ proc check_effective_target_c++ { } {
  return 0
 }
 
-set cxx_default "c++17"
+set cxx_default "c++20"
 # Check whether the current active language standard supports the features
 # of C++11/C++14 by checking for the presence of one of the -std flags.
 # This assumes that the default for the compiler is $cxx_default, and that
index 7cf77a7821a3a5a2435dbb4c5eeb0e3beb12ae2b..fb6982ca8d04011996202698a7efba0a1a5ab079 100644 (file)
@@ -1,5 +1,5 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
-/* { dg-options "-fobjc-exceptions" } */
+/* { dg-options "-fobjc-exceptions -std=gnu++17" } */
 /* { dg-do compile } */
 // { dg-additional-options "-Wno-objc-root-class" }
 
index 4547a756c74050398472a602995277a471daa69c..2423e3068839b912a6d9d6245843a24f1c47a4e7 100644 (file)
@@ -1,5 +1,5 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
-/* { dg-options "-fobjc-exceptions" } */
+/* { dg-options "-fobjc-exceptions -std=gnu++17" } */
 /* { dg-do compile } */
 // { dg-additional-options "-Wno-objc-root-class" }
 
index d1ae9d8c88ca0e71ccb9eb7433aa562c6409bba6..5b1a7f3e57acad471b08da75c61d1b6e36073a2b 100644 (file)
@@ -15,17 +15,17 @@ main ()
   int v, *p;
   p = &x;
   #pragma omp atomic update
-    p[foo (), 0] = 16 + 6 - p[foo (), 0];
+    p[(foo (), 0)] = 16 + 6 - p[(foo (), 0)];
   #pragma omp atomic read
     v = x;
   if (cnt != 2 || v != 16)
     abort ();
   #pragma omp atomic capture
-    v = p[foo () + foo (), 0] = p[foo () + foo (), 0] + 3;
+    v = p[(foo () + foo (), 0)] = p[(foo () + foo (), 0)] + 3;
   if (cnt != 6 || v != 19)
     abort ();
   #pragma omp atomic capture
-    v = p[foo (), 0] = 12 * 1 / 2 + (foo (), 0) + p[foo (), 0];
+    v = p[(foo (), 0)] = 12 * 1 / 2 + ((foo (), 0)) + p[(foo (), 0)];
   if (cnt != 9 || v != 25)
     abort ();
   #pragma omp atomic capture
@@ -46,7 +46,7 @@ main ()
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0]; p[foo (), 0] = (foo (), 7) ? 13 : foo () + 6;
+      v = p[(foo (), 0)]; p[(foo (), 0)] = (foo (), 7) ? 13 : foo () + 6;
     }
   if (cnt != 19 || v != 1)
     abort ();
index 0569d1c6deb435a949e94c3423b4c3a13de74cc5..1c271196840d2d62274033673aadcd76dcb744dc 100644 (file)
@@ -17,17 +17,17 @@ bar ()
   T v, *p;
   p = &x;
   #pragma omp atomic update
-    p[foo (), 0] = 16 + 6 - p[foo (), 0];
+    p[(foo (), 0)] = 16 + 6 - p[(foo (), 0)];
   #pragma omp atomic read
     v = x;
   if (cnt != 2 || v != 16)
     abort ();
   #pragma omp atomic capture
-    v = p[foo () + foo (), 0] = p[foo () + foo (), 0] + 3;
+    v = p[(foo () + foo (), 0)] = p[(foo () + foo (), 0)] + 3;
   if (cnt != 6 || v != 19)
     abort ();
   #pragma omp atomic capture
-    v = p[foo (), 0] = 12 * 1 / 2 + (foo (), 0) + p[foo (), 0];
+    v = p[(foo (), 0)] = 12 * 1 / 2 + ((foo (), 0)) + p[(foo (), 0)];
   if (cnt != 9 || v != 25)
     abort ();
   #pragma omp atomic capture
@@ -48,7 +48,7 @@ bar ()
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0]; p[foo (), 0] = (foo (), 7) ? 13 : foo () + 6;
+      v = p[(foo (), 0)]; p[(foo (), 0)] = (foo (), 7) ? 13 : foo () + 6;
     }
   if (cnt != 19 || v != 1)
     abort ();
index 744b3409c97d175d353dd135c815a693b88fe2ec..9b7fbaa9912c7f65eb5b3bd434f5b07946933865 100644 (file)
@@ -72,22 +72,22 @@ main ()
     abort ();
   p = &x;
   #pragma omp atomic update
-    p[foo (), 0] = p[foo (), 0] - 16;
+    p[(foo (), 0)] = p[(foo (), 0)] - 16;
   #pragma omp atomic read
     v = x;
   if (cnt != 2 || v != 0)
     abort ();
   #pragma omp atomic capture
     {
-      p[foo (), 0] += 6;
-      v = p[foo (), 0];
+      p[(foo (), 0)] += 6;
+      v = p[(foo (), 0)];
     }
   if (cnt != 4 || v != 6)
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0];
-      p[foo (), 0] += 6;
+      v = p[(foo (), 0)];
+      p[(foo (), 0)] += 6;
     }
   if (cnt != 6 || v != 6)
     abort ();
@@ -97,15 +97,15 @@ main ()
     abort ();
   #pragma omp atomic capture
     {
-      p[foo (), 0] = p[foo (), 0] + 6;
-      v = p[foo (), 0];
+      p[(foo (), 0)] = p[(foo (), 0)] + 6;
+      v = p[(foo (), 0)];
     }
   if (cnt != 9 || v != 18)
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0];
-      p[foo (), 0] = p[foo (), 0] + 6;
+      v = p[(foo (), 0)];
+      p[(foo (), 0)] = p[(foo (), 0)] + 6;
     }
   if (cnt != 12 || v != 18)
     abort ();
@@ -114,23 +114,23 @@ main ()
   if (v != 24)
     abort ();
   #pragma omp atomic capture
-  { v = p[foo (), 0]; p[foo (), 0]++; }
+  { v = p[(foo (), 0)]; p[(foo (), 0)]++; }
   #pragma omp atomic capture
-  { v = p[foo (), 0]; ++p[foo (), 0]; }
+  { v = p[(foo (), 0)]; ++p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { p[foo (), 0]++; v = p[foo (), 0]; }
+  { p[(foo (), 0)]++; v = p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { ++p[foo (), 0]; v = p[foo (), 0]; }
+  { ++p[(foo (), 0)]; v = p[(foo (), 0)]; }
   if (cnt != 20 || v != 28)
     abort ();
   #pragma omp atomic capture
-  { v = p[foo (), 0]; p[foo (), 0]--; }
+  { v = p[(foo (), 0)]; p[(foo (), 0)]--; }
   #pragma omp atomic capture
-  { v = p[foo (), 0]; --p[foo (), 0]; }
+  { v = p[(foo (), 0)]; --p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { p[foo (), 0]--; v = p[foo (), 0]; }
+  { p[(foo (), 0)]--; v = p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { --p[foo (), 0]; v = p[foo (), 0]; }
+  { --p[(foo (), 0)]; v = p[(foo (), 0)]; }
   if (cnt != 28 || v != 24)
     abort ();
   return 0;
index ece1bf3f02905a781ac22976ee1703c57693f6c2..937cc48f6136a88bc48ee9ef69084631b3ec338f 100644 (file)
@@ -75,22 +75,22 @@ bar ()
     abort ();
   p = &x;
   #pragma omp atomic update
-    p[foo (), 0] = p[foo (), 0] - 16;
+    p[(foo (), 0)] = p[(foo (), 0)] - 16;
   #pragma omp atomic read
     v = x;
   if (cnt != 2 || v != 0)
     abort ();
   #pragma omp atomic capture
     {
-      p[foo (), 0] += 6;
-      v = p[foo (), 0];
+      p[(foo (), 0)] += 6;
+      v = p[(foo (), 0)];
     }
   if (cnt != 4 || v != 6)
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0];
-      p[foo (), 0] += 6;
+      v = p[(foo (), 0)];
+      p[(foo (), 0)] += 6;
     }
   if (cnt != 6 || v != 6)
     abort ();
@@ -100,15 +100,15 @@ bar ()
     abort ();
   #pragma omp atomic capture
     {
-      p[foo (), 0] = p[foo (), 0] + 6;
-      v = p[foo (), 0];
+      p[(foo (), 0)] = p[(foo (), 0)] + 6;
+      v = p[(foo (), 0)];
     }
   if (cnt != 9 || v != 18)
     abort ();
   #pragma omp atomic capture
     {
-      v = p[foo (), 0];
-      p[foo (), 0] = p[foo (), 0] + 6;
+      v = p[(foo (), 0)];
+      p[(foo (), 0)] = p[(foo (), 0)] + 6;
     }
   if (cnt != 12 || v != 18)
     abort ();
@@ -117,23 +117,23 @@ bar ()
   if (v != 24)
     abort ();
   #pragma omp atomic capture
-  { v = p[foo (), 0]; p[foo (), 0]++; }
+  { v = p[(foo (), 0)]; p[(foo (), 0)]++; }
   #pragma omp atomic capture
-  { v = p[foo (), 0]; ++p[foo (), 0]; }
+  { v = p[(foo (), 0)]; ++p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { p[foo (), 0]++; v = p[foo (), 0]; }
+  { p[(foo (), 0)]++; v = p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { ++p[foo (), 0]; v = p[foo (), 0]; }
+  { ++p[(foo (), 0)]; v = p[(foo (), 0)]; }
   if (cnt != 20 || v != 28)
     abort ();
   #pragma omp atomic capture
-  { v = p[foo (), 0]; p[foo (), 0]--; }
+  { v = p[(foo (), 0)]; p[(foo (), 0)]--; }
   #pragma omp atomic capture
-  { v = p[foo (), 0]; --p[foo (), 0]; }
+  { v = p[(foo (), 0)]; --p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { p[foo (), 0]--; v = p[foo (), 0]; }
+  { p[(foo (), 0)]--; v = p[(foo (), 0)]; }
   #pragma omp atomic capture
-  { --p[foo (), 0]; v = p[foo (), 0]; }
+  { --p[(foo (), 0)]; v = p[(foo (), 0)]; }
   if (cnt != 28 || v != 24)
     abort ();
 }
index f4a6925a40c600b6189279c644a07323d904d049..8c0c2c5225cdce386cf5d43403f96b4b9dcb10bb 100644 (file)
@@ -5,7 +5,8 @@ extern "C" void abort (void);
 volatile int count;
 static int test(void)
 {
-  return ++count > 0;
+  count = count + 1;
+  return count > 0;
 }
 
 int i;
index ebe221adcd5b32e17bbe56435d5c27e37b49e5e6..08c8075112d200f7c7dbf1f57062fdda68ba5e53 100644 (file)
@@ -1,5 +1,6 @@
 // PR c++/38650
 // { dg-do run }
+// { dg-additional-options "-std=gnu++17" }
 
 #include <cstdlib>
 
index 8c39abe80e112f7e42e04b82fe3a4cbedf1ce7f4..e3a71d5db57df14bf36a85a64d2fa48e32a6bbec 100644 (file)
@@ -20,7 +20,7 @@ struct S
 
   auto merge_data_func (int *iptr, int &b)
   {
-    auto fn = [=](void) -> bool
+    auto fn = [=,this](void) -> bool
       {
        bool mapped;
        uintptr_t hostptr = (uintptr_t) ptr;
index d9cbfdcbe7942c2c25243ac17803277cccd71059..da83c6741ca83783e94ca477481b23f05b82748a 100644 (file)
@@ -4,53 +4,53 @@ __attribute__((noipa)) void
 foo (int *p, int i)
 {
   #pragma omp task depend (out: p[0])
-  v++;
+  v = v + 1;
   #pragma omp task depend (in: p[0])
-  v++;
+  v = v + 1;
   #pragma omp task depend (inout: p[0])
-  v++;
+  v = v + 1;
   #pragma omp task depend (mutexinoutset: p[0])
-  v++;
+  v = v + 1;
   #pragma omp task depend (out: p[0]) depend (in: p[1])
-  v++;
+  v = v + 1;
   #pragma omp task depend (in: p[0]) depend (inout: p[1])
-  v++;
+  v = v + 1;
   #pragma omp task depend (inout: p[0]) depend (mutexinoutset: p[1])
-  v++;
+  v = v + 1;
   #pragma omp task depend (mutexinoutset: p[0]) depend (out: p[1])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , out : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , in : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , inout : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , mutexinoutset : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , out : p[j]) depend (iterator (j=0:2) , in : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , in : p[j]) depend (iterator (j=0:2) , inout : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , inout : p[j]) depend (iterator (j=0:2) , mutexinoutset : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:2) , mutexinoutset : p[j]) depend (iterator (j=0:2) , out : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , out : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , in : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , inout : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , mutexinoutset : p[j])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , out : p[j]) depend (iterator (j=0:i) , in : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , in : p[j]) depend (iterator (j=0:i) , inout : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , inout : p[j]) depend (iterator (j=0:i) , mutexinoutset : p[j + 2])
-  v++;
+  v = v + 1;
   #pragma omp task depend (iterator (j=0:i) , mutexinoutset : p[j]) depend (iterator (j=0:i) , out : p[j + 2])
-  v++;
+  v = v + 1;
 }
 
 int
index b46606930556fff174b5e89b48cfa795e0fb4ded..554860ab088c61b18f27041a79a726ac7cd7c2da 100644 (file)
@@ -10,7 +10,7 @@ volatile int v;
 #pragma omp declare target to (v)
 typedef void (*fnp1) (void);
 typedef fnp1 (*fnp2) (void);
-void f1 (void) { v++; }
+void f1 (void) { v += 1; }
 void f2 (void) { v += 4; }
 void f3 (void) { v += 16; f1 (); }
 fnp1 f4 (void) { v += 64; return f2; }