Opened 11 years ago

Closed 11 years ago

#5767 closed Bugs (fixed)

A bug in seeding with sequence in Mersenne Twister

Reported by: Synge Todo <wistaria@…> Owned by: Steven Watanabe
Milestone: To Be Determined Component: random
Version: Boost 1.47.0 Severity: Regression
Keywords: Cc:

Description

There is a bug in boost/random/mersenne_twister.hpp:

   176          // fix up the state if it's all zeroes.
   177          if((x[0] & (~static_cast<UIntType>(0) << r)) == 0) {
   178              for(std::size_t j = 1; i < n; ++j) {
   179                  if(x[j] != 0) return;
   180              }

Since there is a typo in line 178 ("i < n" should be "j < n"), x[0] will always be reset to some constant (static_cast<UIntType>(1) << (w-1)).

Attachments (1)

random.patch (559 bytes ) - added by Synge Todo <wistaria@…> 11 years ago.

Download all attachments as: .zip

Change History (3)

by Synge Todo <wistaria@…>, 11 years ago

Attachment: random.patch added

comment:1 by Marshall Clow, 11 years ago

Owner: changed from No-Maintainer to Steven Watanabe

comment:2 by Steven Watanabe, 11 years ago

Resolution: fixed
Status: newclosed

(In [74169]) Use the right variable. Fixes #5767.

Note: See TracTickets for help on using tickets.