https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94087

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We could do this easily enough (which could be simplified if RDRAND is
guaranteed to be available when RDSEED is available):

--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -105,7 +105,13 @@ namespace std _GLIBCXX_VISIBILITY(default)
       while (__builtin_ia32_rdseed_si_step(&val) == 0)
        {
          if (--retries == 0)
-           std::__throw_runtime_error(__N("random_device: rdseed failed"));
+           {
+#if USE_RDRAND
+             return __x86_rdrand(nullptr);
+#else
+             std::__throw_runtime_error(__N("random_device: rdseed failed"));
+#endif
+           }
          __builtin_ia32_pause();
        }


I'd rather not have to do everything shown at
https://software.intel.com/content/www/us/en/develop/articles/intel-digital-random-number-generator-drng-software-implementation-guide.html
to produce a stronger seed from RDRAND.

Reply via email to