[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
GHC
ghc-devs at haskell.org
Wed Oct 3 10:14:51 UTC 2018
#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
Reporter: mrkkrp | Owner: (none)
Type: bug | Status: patch
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): Phab:D5196
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Oops sorry. I'd modified the code slightly! Try this
{{{
{-# LANGUAGE MagicHash #-}
module Main where
import GHC.Exts (dataToTag#, tagToEnum#, (==#), (<#))
import GHC.Base ( getTag )
main :: IO ()
main = print $ cmpT 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)
cmpT a b
= case getTag a of
a' -> case getTag b of
b' -> if tagToEnum# (a' <# b') :: Bool then
LT
else
if tagToEnum# (a' ==# b') :: Bool then
EQ
else
GT
}}}
Compile with -O and run. It prints `LT` when it should print `EQ`. But
the evals are there!
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:34>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list