diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2013-02-04 17:10:59 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-02-04 17:10:59 +0000 |
commit | 85018f40aedb5d60c63a8f3f85f17d71c84b01ac (patch) | |
tree | c91ef2652e4c4889d527af24d519f129985cfffb | |
parent | 152689dc44791375394b952dbebdfb81e361dffc (diff) | |
download | gcc-85018f40aedb5d60c63a8f3f85f17d71c84b01ac.zip gcc-85018f40aedb5d60c63a8f3f85f17d71c84b01ac.tar.gz gcc-85018f40aedb5d60c63a8f3f85f17d71c84b01ac.tar.bz2 |
re PR libstdc++/56202 (SIGFPE (division by zero) in std::binomial_distribution)
2013-02-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/56202
* include/bits/random.tcc (binomial_distribution<>::
_M_waiting(_UniformRandomNumberGenerator&, _IntType)): Avoid
division by zero.
Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r195722
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/random.tcc | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1a8a822..077e483 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2013-02-04 Manuel López-Ibáñez <manu@gcc.gnu.org> + Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/56202 + * include/bits/random.tcc (binomial_distribution<>:: + _M_waiting(_UniformRandomNumberGenerator&, _IntType)): Avoid + division by zero. + 2013-02-03 Richard Sandiford <rdsandiford@googlemail.com> Update copyright years. diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index ffa3967..6220a5d 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -1658,6 +1658,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION do { const double __e = -std::log(1.0 - __aurng()); + if (__t == __x) + { + if (__e) + return __x; + continue; + } __sum += __e / (__t - __x); __x += 1; } |