On Wed, 17 Dec 2025 at 15:50, Jonathan Wakely <[email protected]> wrote:
>
> 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 -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL is in options.
> ---
>
> This fixes FAILs when -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL is used.
>
> (This is orthogonal to the 32-bit failures)
>
> .../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..5f80be4a392f 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 } }
This should be:
// { dg-skip-if "requires new impl" { *-*-* } {
-D_GLIBCXX_USE_OLD_GENERATE_CANONICAL
-D_GLIBCXX_USE_OLD_GENERATE_CANONICAL=1 } }
So that the test will be skipped as UNSUPPORTED for either -Dblah or -Dblah=1
(it will FAIL for -Dblah=2 or any other values, but I don't care,
getting it working for the sensible cases is what matters here).
>
> #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.
> --
> 2.52.0
>