开发者

ghci segfault with simple math

Can anyone explain this to me? I'm using a recent version of the GHC.

Prelude> let f x = 1/((x**2)-36)  
Prelude> f (0 - 6.5)  
0.16  
Pr开发者_如何转开发elude> f (0 - 5.999)  
-Segmentation fault  
Prelude> f (0 - 5)  
-Segmentation fault

Thanks!

Edit: GHCi version 6.10.4, Mac OS 10.6, Intel Macbook Pro

Edit2: GHCi 7.0.3 doesn't have this problem.


Interesting, I don't get a segfault here (on MacOS this is):

GHCi, version 7.0.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.

Prelude> let f x = 1/((x**2)-36)  
Prelude> f (0 - 6.5)  
0.16
Prelude> f (0 - 5)  
-9.090909090909091e-2
Prelude> 


Works on windows XP with GHC 7.02:

GHCi, version 7.0.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> let f x = 1/((x**2)-36)
Prelude> f (0 - 6.5)
0.16
Prelude> f (0 - 5.999)
-83.34027835650902
Prelude> f (0 - 5)
-9.090909090909091e-2
Prelude>


GHCi version 6.10.4, Mac OS 10.6, Intel Macbook Pro

First thing to do in a situation like this is to check against the most recent stable release of the software.

  • GHC 6.10.4 was released in July 2009.
  • GHC 7.0.3 is available now, in May 2011.

So upgrade to GHC 7.0.3, via the Haskell Platform, and check again.

If you still have a bug, report it via the bug tracker , since any crash requires a high priority bug fix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜