
On 32 bit Windows I get this (with HEAD). 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 The new literal-overflow test objects to 0x80000000 :: Int. I'm not sure if it should object; in this case we are deliberately using the bit-pattern for minBound. Also what happens on a 64-bit architecture? What should the behaviour here be? - should we use minBound here? - what should the new literal-overlflow code do for 0xblah constants? This is currently breaking the HEAD build. Simon

Hey Simon
heres some info about whats happening, and it may point out whats different
http://stackoverflow.com/questions/384502/what-is-the-bit-size-of-long-on-64...
namely: pointers on 64bit windows are 64bit, but c ints are 32bit
hope that helps!
On Sat, Aug 3, 2013 at 5:47 PM, Simon Peyton-Jones
On 32 bit Windows I get this (with HEAD).****
** **
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****
** **
The new literal-overflow test objects to 0x80000000 :: Int. I’m not sure if it should object; in this case we are deliberately using the bit-pattern for minBound.****
** **
Also what happens on a 64-bit architecture?****
** **
What should the behaviour here be? ****
** **
- should we use minBound here?****
- what should the new literal-overlflow code do for 0xblah constants?****
** **
This is currently breaking the HEAD build.****
** **
Simon****
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

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%2... 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

Austin Could you act on this thread please? Currently I think the Windows build is broken because of it. I think Ian is right, namely that the way to get a particular bit-pattern with type 'Int' is to use fromIntegral. But it needs a comment to explain the idiom. eg try compiling this with -O: import Data.Int import Data.Word foo :: Int32 foo = fromIntegral (0x80000000 :: Word32) :: Int32 You get Foo.foo = GHC.Int.I32# (-2147483648) -----Original Message----- From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Ian Lynagh Sent: 05 August 2013 16:34 To: ghc-devs@haskell.org Subject: Re: Literal overflow test fails 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%2... 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 _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

Yes, this slipped by my radar.
I've got my win8 build machine up now, so I can push something shortly.
On Mon, Aug 19, 2013 at 3:40 AM, Simon Peyton-Jones
Austin
Could you act on this thread please? Currently I think the Windows build is broken because of it.
I think Ian is right, namely that the way to get a particular bit-pattern with type 'Int' is to use fromIntegral. But it needs a comment to explain the idiom.
eg try compiling this with -O:
import Data.Int import Data.Word
foo :: Int32 foo = fromIntegral (0x80000000 :: Word32) :: Int32
You get
Foo.foo = GHC.Int.I32# (-2147483648)
-----Original Message----- From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Ian Lynagh Sent: 05 August 2013 16:34 To: ghc-devs@haskell.org Subject: Re: Literal overflow test fails
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%2...
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
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs
-- Regards, Austin - PGP: 4096R/0x91384671
participants (4)
-
Austin Seipp
-
Carter Schonwald
-
Ian Lynagh
-
Simon Peyton-Jones