public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/giulianob/heads/autopar_rebase2)] libstdc++: Fix tests for uninitialized_value_construct_n
@ 2020-08-17 23:55 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-17 23:55 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:f3a54b72856889403e060d39ad42a9ed4607a977

commit f3a54b72856889403e060d39ad42a9ed4607a977
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jun 17 21:23:35 2020 +0100

    libstdc++: Fix tests for uninitialized_value_construct_n
    
    In my recent r11-1460 commit the tests had been "improved" before
    commit, and no longer exercised the code paths changed by the patch.
    
    This restores what I originally tested, so that the tests fail before
    the r11-1460 change and pass after it.
    
            * testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
            Replace Value type with int so trivial code path is used.
            * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
            Likewise.

Diff:
---
 .../uninitialized_default_n/sizes.cc               | 29 +++++-----------------
 .../uninitialized_value_construct_n/sizes.cc       | 29 +++++-----------------
 2 files changed, 12 insertions(+), 46 deletions(-)

diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc
index 1bb4c6a9fb1..6842c76df07 100644
--- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc
@@ -18,25 +18,14 @@
 // { dg-do run { target c++11 } }
 
 #include <memory>
-#include <algorithm>
 #include <testsuite_hooks.h>
 
-struct Value
-{
-  int value = 0x1234;
-};
-
 void
 test01()
 {
-  alignas(Value) unsigned char buf[3 * sizeof(Value) + 1];
-  std::fill(std::begin(buf), std::end(buf), 0xff);
-  const auto p = reinterpret_cast<Value*>(buf);
-  std::__uninitialized_default_n(p, 2.0001);
-  VERIFY( p[0].value == 0x1234 );
-  VERIFY( p[1].value == 0x1234 );
-  VERIFY( p[2].value == 0x1234 );
-  VERIFY( *std::prev(std::end(buf)) == 0xff );
+  int i[3];
+  auto j = std::__uninitialized_default_n(i, 2.0001);
+  VERIFY( j == (i + 3) );
 }
 
 void
@@ -52,16 +41,10 @@ test02()
     int operator>(void*) { return value != 0; }
   };
 
-  alignas(Value) unsigned char buf[4 * sizeof(Value) + 1];
-  std::fill(std::begin(buf), std::end(buf), 0xff);
-  const auto p = reinterpret_cast<Value*>(buf);
+  int i[3];
   Size n = {4};
-  std::__uninitialized_default_n(p, n);
-  VERIFY( p[0].value == 0x1234 );
-  VERIFY( p[1].value == 0x1234 );
-  VERIFY( p[2].value == 0x1234 );
-  VERIFY( p[3].value == 0x1234 );
-  VERIFY( *std::prev(std::end(buf)) == 0xff );
+  auto j = std::__uninitialized_default_n(i, n);
+  VERIFY( j == (i + 4) );
 }
 
 int
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc
index e822b198928..7ad55e01157 100644
--- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc
@@ -19,25 +19,14 @@
 // { dg-do run { target c++17 } }
 
 #include <memory>
-#include <algorithm>
 #include <testsuite_hooks.h>
 
-struct Value
-{
-  int value = 0x1234;
-};
-
 void
 test01()
 {
-  alignas(Value) unsigned char buf[3 * sizeof(Value) + 1];
-  std::fill(std::begin(buf), std::end(buf), 0xff);
-  const auto p = reinterpret_cast<Value*>(buf);
-  std::uninitialized_value_construct_n(p, 2.0001);
-  VERIFY( p[0].value == 0x1234 );
-  VERIFY( p[1].value == 0x1234 );
-  VERIFY( p[2].value == 0x1234 );
-  VERIFY( *std::prev(std::end(buf)) == 0xff );
+  int i[3];
+  auto j = std::uninitialized_value_construct_n(i, 2.0001);
+  VERIFY( j == (i + 3) );
 }
 
 void
@@ -53,16 +42,10 @@ test02()
     int operator>(void*) { return value != 0; }
   };
 
-  alignas(Value) unsigned char buf[4 * sizeof(Value) + 1];
-  std::fill(std::begin(buf), std::end(buf), 0xff);
-  const auto p = reinterpret_cast<Value*>(buf);
+  int i[3];
   Size n = {4};
-  std::uninitialized_value_construct_n(p, n);
-  VERIFY( p[0].value == 0x1234 );
-  VERIFY( p[1].value == 0x1234 );
-  VERIFY( p[2].value == 0x1234 );
-  VERIFY( p[3].value == 0x1234 );
-  VERIFY( *std::prev(std::end(buf)) == 0xff );
+  auto j = std::__uninitialized_default_n(i, n);
+  VERIFY( j == (i + 4) );
 }
 
 int


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-17 23:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 23:55 [gcc(refs/users/giulianob/heads/autopar_rebase2)] libstdc++: Fix tests for uninitialized_value_construct_n Giuliano Belinassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).