[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 06:50:26 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: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.6.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Sometimes.
Here is the thread that explains the bug:
https://github.com/haskell/containers/issues/568
I originally reported this as a bug on `containers` issue tracker, but we
seem to have concluded that this is probably a bug in the GHC optimizer
itself.
I think the shortest repro so far is this:
{{{#!hs
import qualified Data.Set as S
main = print $
let {-# noinline f #-}
f () = T2
in S.fromList [f (), f ()]
data T = T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9
deriving (Show, Read, Eq, Ord, Bounded, Enum)
}}}
which prints
{{{#!hs
fromList [T2,T2]
}}}
The person who derived this from my original repro says:
> And as I said earlier, comment out the T9 constructor => prints fromList
[T2] as it should.
Another interesting quote:
> Can confirm. Tested with ghc-8.6.1, containers-0.6.0.1 and
leancheck-0.7.5 (so it does not seem to depend on the testing framework).
Error occurs:
>
> * with ghc -O1 and -O2 (but not with -O0)
> * and if data type has at least 9 elements
>
> So, likely a bug in ghc's optimizer.
>
> in some cases, input has duplicates, but not always.
This is a bad one, makes GHC 8.6.1 totally unusable for me.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list