[GHC] #13107: Negative literal equal to minBound gives a spurious warning

#13107: Negative literal equal to minBound gives a spurious warning -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In GHCi: {{{ λ > import GHC.Int λ > -128 :: Int8 <interactive>:25:2: warning: [-Woverflowed-literals] Literal 128 is out of the Int8 range -128..127 If you are trying to write a large negative literal, use NegativeLiterals -128 λ > minBound :: Int8 -128 }}} Since `-128 :: Int8` is equal to `minBound :: Int8` this warning is not correct. Similar issues exist for `Int16`, `Int32` etc. Suspect this is related to the fix for #8542. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13107 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13107: Negative literal equal to minBound gives a spurious warning -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): I can avoid the warning if I use the `NegativeLiterals` language pragma. Maybe that language pragma should be a candidate for inclusion as a default for the next haskell language standard. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13107#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13107: Negative literal equal to minBound gives a spurious warning -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => invalid Comment: I don't see the problem here, although the warning requires careful reading. `-128` is the application of unary minus to the literal `128`. The literal `128` that you wrote does indeed lie outside of the `Int8` range as the warning states. And the warning even suggested turning on `NegativeLiterals`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13107#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC