[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
GHC
ghc-devs at haskell.org
Tue Oct 2 15:45:02 UTC 2018
#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
Reporter: mrkkrp | Owner: (none)
Type: bug | Status: new
Priority: highest | Milestone: 8.6.2
Component: Compiler | Version: 8.6.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by monoidal):
Here's a smaller version.
`ghc T15696 && ./T15696` prints `EQ` correctly, `ghc -O T15696 &&
./T15696` prints `LT`.
{{{
#!hs
{-# LANGUAGE MagicHash #-}
module Main where
import GHC.Exts (dataToTag#, tagToEnum#, (==#), (<#))
main :: IO ()
main = print $ compare a T2
where
{-# NOINLINE f #-}
f = T2
{-# NOINLINE a #-}
a = f
data T = T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9
deriving (Eq, Show, Ord)
{-
instance Ord Main.T where
compare a b
= case dataToTag# a of
a' -> case dataToTag# b of
b' -> if tagToEnum# (a' <# b') :: Bool then
LT
else
if tagToEnum# (a' ==# b') :: Bool then
EQ
else
GT
-}
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list