[GHC] #2156: compilation math/truncate bug with optimization
enabled
GHC
trac at galois.com
Wed Mar 19 08:29:08 EDT 2008
#2156: compilation math/truncate bug with optimization enabled
-------------------------+--------------------------------------------------
Reporter: trevorm | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.2
Severity: critical | Resolution:
Keywords: | Testcase:
Architecture: x86 | Os: Linux
-------------------------+--------------------------------------------------
Comment (by trevorm):
On investigating further I see that the optimized code generated is
{{{
subl $8, %esp ; fnstcw 4(%esp)
ffree %st(7) ; fld %st(0)
movzwl 4(%esp), %eax ; orl $0xC00, %eax
movl %eax, 0(%esp) ; fldcw 0(%esp)
fistpl 0(%esp)
fldcw 4(%esp) ; movl 0(%esp), %eax
}}}
which sets rounding mode to chop and then converts to integer. So the
value 2 is correct according to the definition of truncate.
So the optimized code behaves as if the values are Double precision, while
the unoptimized code behaves as if they have better (infinite?) precision
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2156#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list