From patchwork Mon Feb 4 17:18:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [v3] libstdc++/56202 Date: Mon, 04 Feb 2013 07:18:19 -0000 From: Paolo Carlini X-Patchwork-Id: 217994 Message-Id: <510FED5B.3010906@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: libstdc++ Hi, tested x96_64-linux, committed to mainline. Thanks, Paolo. ///////////////////// 2013-02-04 Manuel López-Ibáñez Paolo Carlini PR libstdc++/56202 * include/bits/random.tcc (binomial_distribution<>:: _M_waiting(_UniformRandomNumberGenerator&, _IntType)): Avoid division by zero. Index: include/bits/random.tcc =================================================================== --- include/bits/random.tcc (revision 195717) +++ include/bits/random.tcc (working copy) @@ -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; }