Ghci segfault with simple math

Can someone explain this to me? I am using a recent version of GHC.

Prelude> let f x = 1/((x**2)-36)  
Prelude> f (0 - 6.5)  
0.16  
Prelude> f (0 - 5.999)  
-Segmentation fault  
Prelude> f (0 - 5)  
-Segmentation fault

Thank!

Edit: GHCi version 6.10.4, Mac OS 10.6, Intel Macbook Pro
Edit2: GHCi 7.0.3 does not have this problem.

+3
source share
3 answers

Interestingly, I do not get segfault here (on macOS this):

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> 
+1
source

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>
+1
source

GHCi 6.10.4, Mac OS 10.6, Intel Macbook Pro

, , - .

  • GHC 6.10.4 2009 .
  • GHC 7.0.3 , 2011 .

, GHC 7.0.3 Haskell Platform .

If you still have an error, report it via the error tracker , as any failure requires a high-priority fix.

+1
source

All Articles