[GHC] #9122: Make Lint check for bad uses of `unsafeCoerce`

GHC ghc-devs at haskell.org
Mon May 19 09:05:36 UTC 2014


#9122: Make Lint check for bad uses of `unsafeCoerce`
------------------------------------+-------------------------------------
       Reporter:  simonpj           |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.8.2
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 I think it would be a great idea for Core Lint to check for uses of
 `unsafeCoerce` that don't obey the rules.  It won't catch all cases, of
 course, but it would have caught #9035. Specficially, look for:
  * Coercions between lifted and unboxed types
  * Coercion between unboxed types of different sizes
  * Coercion between unboxed ints and floats.

 Would anyone like to make a patch for this?  Anything that can be checked
 by Core Lint, should be checked!

 I'm afraid I don't know where to look for the reason for the int/float
 difficulty.  I'd write a tiny function that exhibits the unsafe conversion
 and look the code it generates.

 Simon

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


More information about the ghc-tickets mailing list