[openacc, testsuite] Fix undefined behaviour in atomic_capture-1.c
authorJulian Brown <julian@codesourcery.com>
Sun, 29 Apr 2018 10:26:56 +0000 (10:26 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Sun, 29 Apr 2018 10:26:56 +0000 (10:26 +0000)
2018-04-29  Julian Brown  <julian@codesourcery.com>
    Tom de Vries  <tom@codesourcery.com>

PR testsuite/85527
* testsuite/libgomp.oacc-c-c++-common/atomic_capture-1.c: Allow
arbitrary order for iterations of atomic subtract check.

Co-Authored-By: Tom de Vries <tom@codesourcery.com>
From-SVN: r259748

libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/atomic_capture-1.c

index 0ba1bbef4929c85f261192dfc3e30d6e773fbd0e..49364dac094517db0b906dfc1be93d2dab65fa78 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-29  Julian Brown  <julian@codesourcery.com>
+           Tom de Vries  <tom@codesourcery.com>
+
+       PR testsuite/85527
+       * testsuite/libgomp.oacc-c-c++-common/atomic_capture-1.c: Allow
+       arbitrary order for iterations of atomic subtract check.
+
 2018-04-28  Tom de Vries  <tom@codesourcery.com>
 
        PR testsuite/85527
index ad958cd1f9eaaf8aec13de614963618d0d85b98a..9b71a0875ad5f6b0987a373ac520524fa8016d3e 100644 (file)
@@ -795,17 +795,16 @@ main(int argc, char **argv)
       }
   }
 
+  int ones = 0, thirtyones = 0;
+
   for (i = 0; i < N; i++)
-    if (i % 2 == 0)
-      {
-       if (fdata[i] != 31.0)
-         abort ();
-      }
-    else
-      {
-       if (fdata[i] != 1.0)
-         abort ();
-      }
+    if (fdata[i] == 31.0)
+      thirtyones++;
+    else if (fdata[i] == 1.0)
+      ones++;
+
+  if (ones != N / 2 || thirtyones != N / 2)
+    abort ();
 
 
   /* BINOP = / */