[GHC] #11826: unsafe causes bug, news @ 11

GHC ghc-devs at haskell.org
Wed Apr 13 01:58:13 UTC 2016


#11826: unsafe causes bug, news @ 11
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I know there has been plenty of levity here lately but here goes :)

 I didn't expect ‘isUndefined’ to be safe but this may be interesting to
 the devs (I am obedient and report it thusly and hereby-ly per GHC's
 request)

 {{{#!haskell
 % ghci -ignore-dot-ghci
 GHCi, version 8.1.20160117: http://www.haskell.org/ghc/  :? for help
 Prelude> import Control.Exception
 Prelude Control.Exception> import System.IO.Unsafe
 Prelude Control.Exception System.IO.Unsafe> import Unsafe.Coerce
 Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined x =
 unsafePerformIO $ catch ((unsafeCoerce x :: IO ()) >> return False) (const
 $ return True :: SomeException -> IO Bool)
 Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined
 (succ True)
 True
 Prelude Control.Exception System.IO.Unsafe Unsafe.Coerce> isUndefined
 (succ False)
 <interactive>: internal error: stg_ap_v_ret
     (GHC version 8.1.20160117 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 Aborted (core dumped)
 %
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11826>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list