[Haskell-cafe] Optimization flag changing result of code execution
Jan-Willem Maessen
jmaessen at alum.mit.edu
Wed Jul 17 14:03:07 CEST 2013
This has all the marks of a 64-bit-only code running on a 32 bit machine.
It looks like you're getting the high bits of the rng with a signed shift
right, ultimately yielding only the sign bit.
I suspect mwc-random needs to use Int64 rather than Int internally in a few
critical places.
On Wed, Jul 17, 2013 at 7:22 AM, kudah <kudahkukarek at gmail.com> wrote:
> Test triggers the bug, only zeros and ones like you said, but
> only for native-sized types:
>
> -O2:
> Int
> 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0
> Int32
> 41 37 25 85 27 84 70 8 70 32 36 1 14 92 1 74 17 28 38 76
> Int64
> 37 77 57 75 17 58 28 77 23 51 1 13 50 35 21 11 70 43 6 5
> Word
> 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0
> Word32
> 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0
> Word64
> 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29
>
> ghci:
> Int
> 53 13 24 58 66 71 19 16 73 54 95 87 2 34 62 67 2 45 56 2
> Int32
> 41 37 25 85 27 84 70 8 70 32 36 1 14 92 1 74 17 28 38 76
> Int64
> 37 77 57 75 17 58 28 77 23 51 1 13 50 35 21 11 70 43 6 5
> Word
> 41 19 99 69 27 58 92 45 9 38 51 39 50 14 2 21 25 94 96 2
> Word32
> 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0
> Word64
> 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29
>
> I run a 32-bit system, as I've said before.
>
> > Gentoo Linux _i686_ 3.8.2-pf
>
> Could perhaps be something with my system, I'll test on Ubuntu later
> today, and if there are no problems with compiling mwc-random on ghc
> git — on it too.
>
> On Wed, 17 Jul 2013 12:19:29 +0400 Aleksey Khudyakov
> <alexey.skladnoy at gmail.com> wrote:
>
> > On 10 July 2013 14:10, kudah <kudahkukarek at gmail.com> wrote:
> > > Yes, it does. Without optimizations the result is
> > > "ndgorsfesnywaiqraloa", while with optimizations the result is
> > > always "aaaaaaaaaabbaaaaaaaa".
> > >
> > Sorry for taking so long. So problem is uniformR. You can reproduce
> > bug reliably and I cannot. Are you on 32-bit system? I only tested on
> > 64-bit ones. If this isn't the case I'm out of ideas.
> >
> > I finally wrote test case that doesn't depends on anything besides
> > mwc-random (it's
> > in attachment). Could you check whether it still triggers the bug
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130717/f46eac9d/attachment.htm>
More information about the Haskell-Cafe
mailing list