STL std::random_shuffle behavior fails with lrand48

Jim Kleckner jek-cygwin@kleckner.net
Sat Jul 31 12:10:00 GMT 2004


Attached is a simple test case of std::random_shuffle() that
gives different answers on cygwin and RH Linux.  Note that
the output looks like a simple circular rotation on cygwin
but works correctly on RH 7.2.  The problem appears to be
the implementation of lrand48().  If you undefine:
  #undef _GLIBCPP_HAVE_DRAND48
then it works consistently.

On cygwin output is:
changes before:
0 1 2 3 4 5 6
changes after:
6 0 1 2 3 4 5
changes after:
5 6 0 1 2 3 4
changes after:
4 5 6 0 1 2 3

========
on RH7.2 output is:
changes before:
0 1 2 3 4 5 6
changes after:
1 4 2 3 5 6 0
changes after:
0 6 2 1 4 5 3
changes after:
0 1 3 6 5 4 2

=========

Version of cygwin is current (see attached file
for all version stamps)
gcc                     3.3.1-3
gcc-g++                 3.3.1-3

version of gcc/g++ on Linux is 2.96.

The test program is attached as is cygcheck output.

To run it just type (note that -mno-cygwin is *not* used):
g++ xxx.cpp
./a.exe

Is this a configuration issue?  Or does lrand48 not work?
Or is it a long vs. int type mismatch?

Jim
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040731/0a650bef/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: xxx.cpp
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040731/0a650bef/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list