diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-01-18 17:18:47 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-01-18 17:18:47 +0000 |
commit | b08fdbb8450a578846ad69b00b89a80ef24a5203 (patch) | |
tree | fc6bff688d2b70a42fe49ab4cdcb2d2855462fbb /libstdc++-v3/include/experimental/random | |
parent | 46c4e8a1cf8a42947c38cf4a012e5fee45cdfe83 (diff) | |
download | gcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.zip gcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.tar.gz gcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.tar.bz2 |
PR68925 don't use thread_local static for stateless object
PR libstdc++/68925
* include/experimental/random (randint): Use temporary instead of
thread_local static.
From-SVN: r244584
Diffstat (limited to 'libstdc++-v3/include/experimental/random')
-rw-r--r-- | libstdc++-v3/include/experimental/random | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libstdc++-v3/include/experimental/random b/libstdc++-v3/include/experimental/random index 9d5415e..e28df5d 100644 --- a/libstdc++-v3/include/experimental/random +++ b/libstdc++-v3/include/experimental/random @@ -54,8 +54,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(is_integral<_IntType>::value && sizeof(_IntType) > 1, "argument must be an integer type"); using _Dist = std::uniform_int_distribution<_IntType>; - static thread_local _Dist __dist; - return __dist(_S_randint_engine(), typename _Dist::param_type{__a, __b}); + // This relies on the fact our uniform_int_distribution is stateless, + // otherwise we'd need a static thread_local _Dist and pass it + // _Dist::param_type{__a, __b}. + return _Dist(__a, __b)(_S_randint_engine()); } inline void |