Literal overflow test fails

Ian Lynagh igloo at earth.li
Mon Aug 5 17:34:21 CEST 2013


On Sat, Aug 03, 2013 at 09:47:07PM +0000, Simon Peyton-Jones wrote:
> 
> libraries\Win32\Graphics\Win32\GDI\HDC.hs:145:14: Warning:
>     Literal 2147483648 of type Int overflows
> 
> The offending code is:
> 
> setTextCharacterExtra dc extra =
>   failIf (== 0x80000000) "SetTextCharacterExtra" $
>     c_SetTextCharacterExtra dc extra
> 
> - should we use minBound here?

The spec defines the failure value as 0x80000000, so it would be better
to use that constant:
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd145092%28v=vs.85%29.aspx

I had a similar problem with a 0xdeadbeef constant in the compiler
source. I changed it to be
    fromIntegral (0xdeadbeef :: Word32)
instead. I'd suggest doing similarly for the 0x80000000.

> - what should the new literal-overlflow code do for 0xblah constants?

In my opinion, it's doing the right thing.


Thanks
Ian





More information about the ghc-devs mailing list