[Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Peter Verswyvelen
For days I'm fighting against a weird bug. My Haskell code calls into a C function residing in a DLL (I'm on Windows, the DLL is generated using Visual Studio). This C function computes a floating point expression. However, the floating point result is incorrect. I think I found the source of the

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Malcolm Wallace
Interesting. This could be the cause of a weird floating point bug that has been showing up in the ghc testsuite recently, specifically affecting MacOS/Intel (but not MacOS/ppc). http://darcs.haskell.org/testsuite/tests/ghc-regress/lib/Numeric/num009.hs That test compares the result of

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Peter Verswyvelen
Well this situation can indeed not occur on PowerPCs since these CPUs just have floating point registers, not some weird dual stack sometimes / registers sometimes architecture. But in my case the bug is consistent, not from time to time. So I'll try to reduce this to a small reproducible test

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Zachary Turner
What floating point model is your DLL compiled with? There are a variety of different options here with regards to optimizations, and I don't know about the specific assembly that each option produces, but I know there are options like Strict, Fast, or Precise, and maybe when you do something

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Peter Verswyvelen
I tried both precise and fast, but that did not help. Compiling to SSE2 fixed it, since that does not use a floating point stack I guess. I'm preparing a repro test case, but it is tricky since removing code tends to change the optimizations and then the bug does not occur. Does anybody know what

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Ian Lynagh
On Fri, Apr 03, 2009 at 10:10:17PM +0200, Peter Verswyvelen wrote: I tried both precise and fast, but that did not help. Compiling to SSE2 fixed it, since that does not use a floating point stack I guess. You didn't say what version of GHC you are using, but it sounds like this might already be

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Peter Verswyvelen
Ouch, what a waste of time on my side :-( This bugfix is not mentioned in the notable bug fixes herehttp://haskell.org/ghc/docs/6.10.2/html/users_guide/release-6-10-2.html Since this is such a severe bug, I would recommend listing it :) Anyway, I have a very small repro test case now. Will

Re: [Haskell-cafe] Possible floating point bug in GHC?

2009-04-03 Thread Peter Verswyvelen
Okay, I can confirm the bug is fixed. It's insane this bug did not cause any more problems. Every call into every C function that uses floating point could have been affected (OpenGL, BLAS, etc) On Fri, Apr 3, 2009 at 10:47 PM, Peter Verswyvelen bugf...@gmail.comwrote: Ouch, what a waste of