When the default constructor was split out into a separate function (in
r261522) I accidentally  made it call _M_init("mt19937") instead of
_M_init_pretr1("mt19937"). That means it will always throw an exception,
because "mt19937" isn't a valid token accepted by the _M_init function.
Restore the original behaviour by calling _M_init_pretr1("mt19937").

        * include/bits/random.h (random_device) [!_GLIBCXX_USE_DEV_RANDOM]:
        Fix default constructor to call correct function.

Tested x86_64-w64-ming32, committed to trunk.

commit 17aac41d36d894e96b816ae97f5942871e65b254
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Oct 16 23:34:23 2018 +0100

    Fix regression in std::random_device default constructor
    
    When the default constructor was split out into a separate function (in
    r261522) I accidentally  made it call _M_init("mt19937") instead of
    _M_init_pretr1("mt19937"). That means it will always throw an exception,
    because "mt19937" isn't a valid token accepted by the _M_init function.
    Restore the original behaviour by calling _M_init_pretr1("mt19937").
    
            * include/bits/random.h (random_device) [!_GLIBCXX_USE_DEV_RANDOM]:
            Fix default constructor to call correct function.

diff --git a/libstdc++-v3/include/bits/random.h 
b/libstdc++-v3/include/bits/random.h
index 5e994aa8836..e02a185e3f0 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -1611,7 +1611,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     ~random_device()
     { _M_fini(); }
 #else
-    random_device() { _M_init("mt19937"); }
+    random_device() { _M_init_pretr1("mt19937"); }
 
     explicit
     random_device(const std::string& __token)

Reply via email to