On 32-bit x86 the default -fexcess-precision=fast setting used by
-std=gnu++20 results in unpredictable rounding which alters the number
of times that std::generate_canonical produces exactly 1.0f, which
means that the URBG is invoked a different number of times.

To ensure that the behaviour is consistent and the expected number of
calls happens, use -fexcess-precision=standard.

libstdc++-v3/ChangeLog:

        * 
testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc:
        Add -fexcess-precision=standard to options.
        * 
testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc:
        Likewise.
---

Tested x86_64-linux
Also checked -m32 and -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL

 .../random/uniform_real_distribution/operators/64351.cc          | 1 +
 .../random/uniform_real_distribution/operators/gencanon.cc       | 1 +
 2 files changed, 2 insertions(+)

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 3031984df15a..f457bc6e0fc9 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
@@ -17,6 +17,7 @@
 
 // { dg-do run { target { c++11 && { ! simulator } } } }
 // { dg-require-cstdint "" }
+// { dg-additional-options -fexcess-precision=standard }
 
 #include <random>
 #include <testsuite_hooks.h>
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 87ad206a78a4..69a061071da0 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,5 +1,6 @@
 // { 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 } 
}
+// { dg-additional-options -fexcess-precision=standard }
 
 #include <random>
 #include <limits>
-- 
2.52.0

Reply via email to