that's interesting - also, I thought everybody was supposed to be using 
<tr1/random> these days. am I behind?  is <random> gcc-specific, or will this 
work in DJGPP, VC++, embarcadero, metrowerks, and other compilers?

whatever I use, I want my code to be cross-platform and cross-compiler as much 
as possible.
thanks for your help...

the compiler I am using is mingw-w32-bin_i686-mingw_20111127 auto build if it 
makes any difference.

I get 
Thu 03/15/2012 22:30:22.23|C:\prj\test\mingw-w64\uniform_int-bug|>32\tr1
<random>...
15028999435905310454
16708911996216745849
02342493223442167775
16848810653347327969
11664969248402573611
01799302827895858725
05137385360522333466
10088183424363624464
17662883439475955428
17799051847008967418
<tr1/random>...
00000000003499211612
00000000000581869302
00000000003890346734
00000000003586334585
00000000000545404204
00000000004161255391
00000000003922919429
00000000000949333985
00000000002715962298
00000000001323567403

Thu 03/15/2012 22:30:29.26|C:\prj\test\mingw-w64\uniform_int-bug|>
on your same source code, so it's not just the 64-bit compiler.

there is a fair difference between the files
c:\mingw-w32-bin_i686-mingw_20111127\mingw/include/c++/4.7.0/tr1/random
c:\mingw-w32-bin_i686-mingw_20111127\mingw/include/c++/4.7.0/random


the latter depends upon bits, the former depends upon tr1/directory for its 
implementation of uniform_int and mt19937, etc.
They are totally different animals.  and I am not sure why.  but tr1 is 
definitely broken.  somebody is using an int in there somewhere.


it turns out this is also a bug in DJGPP.  so this is a bug in gcc itself.
who wants to do the bug report?






>________________________________
> From: K. Frank <[email protected]>
>To: [email protected] 
>Sent: Wednesday, March 14, 2012 7:31 PM
>Subject: Re: [Mingw-w64-public] problem with <random>'s uniform_int?
> 
>Hello Jim and Kai and Ruben and Friends!
>
>I see something similar to Jim's bug in <tr1/random>, but
>not in <random>.
>
>On Wed, Mar 14, 2012 at 2:22 AM, Jim Michaels <[email protected]> wrote:
>> /*
>> Author: Jim Michaels
>> ...
>> #include <tr1/random>
>> ...
>> //problem: this hovers way too long around
>> /*
>> sample output:
>> 18446744072913795932
>> 18446744073304931054
>> 18446744073000918905
>> 18446744073575839711
>> 18446744073337503749
>> ...
>
>First, Jim's observation does look like a bug to me.  I don't see anything
>in his code that looks wrong (but I often overlook things).
>
>Also, when I run a similar test program, I see a similar problem when I
>use <tr1/random>:
>
>   00000000003499211612
>   00000000000581869302
>   00000000003890346734
>   00000000003586334585
>   00000000000545404204
>
>but not when I use <random>.
>
>   15028999435905310454
>   16708911996216745849
>   02342493223442167775
>   16848810653347327969
>   11664969248402573611
>
>(One speculation on the difference between Jim's bug observation
>and mine:  Maybe the high-order word isn't getting set by uniform_int,
>and for some reason Jim is getting garbage in the high-order word,
>while I am getting zero.)
>
>My complete program and output follow, below.
>
>Note, I am using one of Ruben's std::thread-enabled 4.7.0 64-bit
>builds.
>
>I suppose that there is a bug, but if I'm right that it's only in
><tr1/random>, I'm not sure how much we care.  Maybe the
>bug fix should be to junk tr1.  I don't have much appetite for
>investigating tr1 any further as c++11's <random> seems to
>be working correctly in this regard.
>
>> ...
>> Jim Michaels
>> ...
>
>Thanks for bringing this up, and Happy Hacking!
>
>K. Frank
>
>--- program details ---
>
>C:\random_test>type uniform_test.cpp
>#include <iostream>
>#include <random>
>#include <tr1/random>
>
>int main () {
>  std::cout << "<random>..." << std::endl;
>  std::mt19937 mte;
>  std::uniform_int_distribution<unsigned long long> ull_dist {0ULL,
>0xffffffffffffffffULL};
>
>  for (unsigned i = 0; i < 10; i++) {
>    std::cout.fill('0');
>    std::cout.width(20);
>    std::cout << ull_dist (mte) << std::endl;
>  }
>
>  std::cout << "<tr1/random>..." << std::endl;
>  std::tr1::mt19937 mte2;
>  std::tr1::uniform_int<unsigned long long> ull_dist2 {0ULL,
>0xffffffffffffffffULL};
>
>  for (unsigned i = 0; i < 10; i++) {
>    std::cout.fill('0');
>    std::cout.width(20);
>    std::cout << ull_dist2 (mte2) << std::endl;
>  }
>
>  return 0;
>}
>
>C:\random_test>g++ --version
>g++ (GCC) 4.7.0 20110829 (experimental)
>Copyright (C) 2011 Free Software Foundation, Inc.
>This is free software; see the source for copying conditions.  There is NO
>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>
>C:\random_test>g++ -std=c++0x -o uniform_test uniform_test.cpp
>
>C:\random_test>uniform_test
><random>...
>15028999435905310454
>16708911996216745849
>02342493223442167775
>16848810653347327969
>11664969248402573611
>01799302827895858725
>05137385360522333466
>10088183424363624464
>17662883439475955428
>17799051847008967418
><tr1/random>...
>00000000003499211612
>00000000000581869302
>00000000003890346734
>00000000003586334585
>00000000000545404204
>00000000004161255391
>00000000003922919429
>00000000000949333985
>00000000002715962298
>00000000001323567403
>
>C:\random_test>
>
>------------------------------------------------------------------------------
>This SF email is sponsosred by:
>Try Windows Azure free for 90 days Click Here 
>http://p.sf.net/sfu/sfd2d-msazure
>_______________________________________________
>Mingw-w64-public mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>
>
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to