diff options
| author | emsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-30 00:25:17 +0000 |
|---|---|---|
| committer | emsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-30 00:25:17 +0000 |
| commit | 62a287fda74c258ff5acdb5d2711d325b2d21651 (patch) | |
| tree | 4d7143f73d43dbbead187fe36c1b155435b44c01 /libstdc++-v3/include | |
| parent | 6f449ff3da8f442f06e48e3575c45efdf3b29248 (diff) | |
| download | ppe42-gcc-62a287fda74c258ff5acdb5d2711d325b2d21651.tar.gz ppe42-gcc-62a287fda74c258ff5acdb5d2711d325b2d21651.zip | |
2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
PR libstdc++/60037 - SIGFPE in std::generate_canonical<unsigned int...>
* include/bits/random.h (_Adaptor): static_assert for non floating-point
result type.
* include/bits/random.tcc (generate_canonical): Ditto.
* include/ext/random.tcc (hypergeometric_distribution::operator()):
Use double as a rng result type.
* testsuite/26_numerics/random/pr60037-neg.cc: New.
* testsuite/ext/random/hypergeometric_distribution/pr60037.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@213231 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
| -rw-r--r-- | libstdc++-v3/include/bits/random.h | 2 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/random.tcc | 3 | ||||
| -rw-r--r-- | libstdc++-v3/include/ext/random.tcc | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index edfd797b722..b34dbe659ed 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -164,6 +164,8 @@ _GLIBCXX_END_NAMESPACE_VERSION template<typename _Engine, typename _DInputType> struct _Adaptor { + static_assert(std::is_floating_point<_DInputType>::value, + "template argument not a floating point type"); public: _Adaptor(_Engine& __g) diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index 0eda287f481..8849ee90d64 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -3463,6 +3463,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _RealType generate_canonical(_UniformRandomNumberGenerator& __urng) { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + const size_t __b = std::min(static_cast<size_t>(std::numeric_limits<_RealType>::digits), __bits); diff --git a/libstdc++-v3/include/ext/random.tcc b/libstdc++-v3/include/ext/random.tcc index dd7a14a422d..fec7f862b52 100644 --- a/libstdc++-v3/include/ext/random.tcc +++ b/libstdc++-v3/include/ext/random.tcc @@ -1314,7 +1314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator()(_UniformRandomNumberGenerator& __urng, const param_type& __param) { - std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + std::__detail::_Adaptor<_UniformRandomNumberGenerator, double> __aurng(__urng); result_type __a = __param.successful_size(); |

