#7453: unsafe coerce without extensions
Reporter:  guest                        |          Owner:                       
    Type:  bug                          |         Status:  new                  
Priority:  normal                       |      Component:  Compiler (Type 
 Version:  7.6.1                        |       Keywords:                       
      Os:  Unknown/Multiple             |   Architecture:  Unknown/Multiple     
 Failure:  GHC accepts invalid program  |      Blockedby:                       
Blocking:                               |        Related:                       
 The following program implements an unsafe coerce and works on versions of
 GHC at least as far back as 7.0.3 but is fixed in HEAD. I'm reporting this
 because I don't know if it was fixed on purpose and might merit at least a
 fix to the 7.6.X branch if not the 7.4.X branch (due to its use in the

 newtype Id a = Id { runId :: a }

 -- Providing this type triggers a type-error
 -- cast :: a -> b
 cast v = runId z
   z :: Id v
   z = aux
     aux = Id v

 Example usage:
 *Main> map cast [97..107 :: Int] :: String

 *Main> cast (Just True) :: String
 "\-1152921504589708267Segmentation fault: 11

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

Glasgow-haskell-bugs mailing list

Reply via email to