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

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Jun 27 11:31:02 2019
New Revision: 272748

URL: https://gcc.gnu.org/viewcvs?rev=272748&root=gcc&view=rev
Log:
PR libstdc++/85494 use rand_s in std::random_device

This is a minimal fix for the use of a deterministic RNG on mingw-w64,
simply using rand_s unconditionally. The rest of the r271740 changes on
trunk are not included. That means that RDSEED and RDRAND are not
available for mingw-w64 and the token passed to the constructor is
ignored completely.

        PR libstdc++/85494 use rand_s in std::random_device
        * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_CRT_RAND_S): Define.
        * src/c++11/cow-string-inst.cc (random_device::_M_init_pretr1)
        [_GLIBCXX_USE_CRT_RAND_S]: Do nothing if rand_s will be used.
        * src/c++11/random.cc [_GLIBCXX_USE_CRT_RAND_S] (__winxp_rand_s):
        Define new function.
        (random_device::_M_init_pretr1) [_GLIBCXX_USE_CRT_RAND_S]: Do nothing
        if rand_s will be used.
        (random_device::_M_getval_pretr1) [_GLIBCXX_USE_CRT_RAND_S]: Use
        __winxp_rand_s().
        * testsuite/26_numerics/random/random_device/85494.cc: New test.

Added:
   
branches/gcc-9-branch/libstdc++-v3/testsuite/26_numerics/random/random_device/85494.cc
Modified:
    branches/gcc-9-branch/libstdc++-v3/ChangeLog
    branches/gcc-9-branch/libstdc++-v3/config/os/mingw32-w64/os_defines.h
    branches/gcc-9-branch/libstdc++-v3/src/c++11/cow-string-inst.cc
    branches/gcc-9-branch/libstdc++-v3/src/c++11/random.cc

Reply via email to