Derived Ord instance for enumerations with more than 8 elements seems to be incorrect
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:
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
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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |