It also works (exposes the bug on x86) without Quickcheck and Doubles:
main = prop 6.0 0.109998815
prop m x = do
let a = x * m
putStrLn (show a ++ " foo")
print (x * m == a)
0.65999289 foo
False
The middle line seems to prevent CSE.
C.
Am 10.07.2012 13:06, schrieb Sönke Hahn:
I've attached the code. The code does not make direct use of
unsafePerformIO. It uses QuickCheck, but I don't think, this is a
QuickCheck bug. The used Eq-instance is the one for Float.
I've only managed to reproduce this bug on 32-bit-linux with ghc-7.4.2
when compiling with -O2.
(The code might seem a bit odd, but this is the most boiled down version
I could come up with. Even removing the "module Main where" line changes
the behaviour.)
Cheers,
Sönke
On 07/10/2012 12:51 PM, malcolm.wallace wrote:
Also, it is more likely to be a buggy instance of Eq, than a real loss
of referential transparency.
Regards,
Malcolm
On Jul 10, 2012, at 11:49 AM, Christopher Done <chrisd...@gmail.com> wrote:
Depends what the real offending code is. For example, if it contains
unsafePerformIO then it's not a bug.
On 10 July 2012 12:42, Sönke Hahn <sh...@cs.tu-berlin.de
<mailto:sh...@cs.tu-berlin.de>> wrote:
Hi!
I've discovered a strange bug that violates simple equational reasoning.
Basically, something similar to this:
let a = f x
in a == f x
evaluates to False.
I'd like to report this on ghc-trac, but I realised, that I don't know a
good name for behaviour like this. Is there one? "Broken referential
transparency", perhaps?
Thanks,
Sönke
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
<mailto:Glasgow-haskell-users@haskell.org>
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
<mailto:Glasgow-haskell-users@haskell.org>
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users