a miscompilation of (`rem` 0x40000000)::Int with -O -fvia-C
eival has the wrong value in this fairly minimal testcase:
module Eival(eival) where
eival :: [Int]
eival = syn [-727299164,-506030719,-906763000,-1356112363,-1183678614,-970206674,-56]
syn :: [Int] -> [Int]
syn (d:ds) = case rem d 0x40000000 of
synD -> ((:) {-$!-} synD) {-$!-} (syn ds) --strictness/($!)s entirely optional
syn [] = []
expected (and gotten with -O0 or -fasm (or hugs :)): [-727299164,-506030719,-906763000,-282370539,-109936790,-970206674,-56] buggy value: [346442660,567711105,166978824,791371285,963805034,103535150,1073741768]
If the denominator is 0x40000001 or 0x3fffffff, the bug does not occur.
Verified in 6.6.1 and 6.7 on x86-32 Linux.
Only is buggy with both -O and -fvia-C. Adding -optc-O0 or -optc-O3 doesn't change the results.
]gcc --version
gcc (GCC) 4.1.2
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Linux |
| Architecture | x86 |