[gcc r16-6225] libstdc++: Adjust tests to work for -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL
Jonathan Wakely
redi@gcc.gnu.org
Wed Dec 17 20:41:57 GMT 2025
https://gcc.gnu.org/g:53893d44f3fec79134f4b43436a7d591985a711d
commit r16-6225-g53893d44f3fec79134f4b43436a7d591985a711d
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Dec 17 13:58:21 2025 +0000
libstdc++: Adjust tests to work for -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL
libstdc++-v3/ChangeLog:
* testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc
[_GLIBCXX_USE_OLD_GENERATE_CANONICAL]: Restore test01. Do not discard an
extra value in test02.
* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc:
Skip if _GLIBCXX_USE_OLD_GENERATE_CANONICAL is defined in options.
Diff:
---
.../uniform_real_distribution/operators/64351.cc | 25 ++++++++++++++++++++++
.../operators/gencanon.cc | 3 ++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc
index 80818df855e8..3031984df15a 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc
@@ -21,6 +21,25 @@
#include <random>
#include <testsuite_hooks.h>
+// libstdc++/64351
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
+ std::mt19937 rng(8890);
+ std::uniform_real_distribution<float> dist;
+
+ rng.discard(30e6);
+ for (long i = 0; i < 10e6; ++i)
+ {
+ auto n = dist(rng);
+ VERIFY( n != 1.f );
+ }
+#else
+ // New generate_canonical is tested in ./gencanon.cc
+#endif
+}
+
// libstdc++/63176
void
test02()
@@ -37,13 +56,19 @@ test02()
rng2.discard(1);
}
+
// PR libstdc++/80137
+#ifdef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
+ // Each std::generate_canonical call should consume exactly one value.
+#else
rng2.discard(1); // account for a 1.0 generated and discarded.
+#endif
VERIFY( rng == rng2 );
}
int
main()
{
+ test01();
test02();
}
diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc
index 40061daa31c0..87ad206a78a4 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc
@@ -1,4 +1,5 @@
// { dg-do run { target { c++11 && { ! simulator } } } }
+// { dg-skip-if "requires new impl" { *-*-* } { -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL=1 } }
#include <random>
#include <limits>
@@ -17,7 +18,7 @@ struct local_rng : std::mt19937
local_rng(std::mt19937 const& arg) : std::mt19937(arg) {}
};
-// Verify P0952R9 implementation requiring a second round-trip
+// Verify P0952R2 implementation requiring a second round-trip
// if first yields exactly 1. In this test, the RNG delivering
// 32 bits per call is seeded such that this occurs once on the
// sixth iteration for float, and not at all for double.
More information about the Libstdc++-cvs
mailing list