plusWord2# is buggy
Looks like its behavior differs between optimization levels:
{-# LANGUAGE MagicHash, UnboxedTuples #-}
import GHC.Prim
import GHC.Word
big :: Word
big = maxBound
good = let x = case big of W# w -> w in case plusWord2# x x of (# a, b #) -> (W# a, W# b)
main = do
putStrLn $ case good of
(0, z) -> "Such optimal, much sad"
(1, z) -> "No optimization here"
I thought I was going crazy! Try the above code with and without -O2 and you'll get different output.
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |