Different random shuffles generated when compiled with gdc than with dmd

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 30 09:13:48 PDT 2014


On Friday, 30 May 2014 at 13:39:18 UTC, Andrew Brown wrote:
> Hi there,
>
> The following code:
>
> void main(){
>    import std.array : array;
>    import std.stdio : writeln;
>    import std.random : rndGen, randomShuffle;
>    import std.range : iota;
>
>    rndGen.seed(12);
>    int[] temp = iota(10).array;
>    randomShuffle(temp);
>    writeln(temp);
> }
>
> writes [1, 8, 4, 2, 0, 7, 5, 6, 9, 3] if it's compiled with dmd,
> but [1, 7, 4, 6, 2, 9, 5, 0, 3, 8] with gdc.
>
> ...
>
> Andrew

Are you sure you are compiling with the same version of dmd and 
gdc? Fixes were made to the rand.d library in the latest release, 
which could explain the difference you are observing.


More information about the Digitalmars-d-learn mailing list