Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,976
    • Issues 4,976
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 479
    • Merge requests 479
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1910
Closed
Open
Created Nov 20, 2007 by Bertram Felgenhauer@int-eReporter

Native Code gen miscompiles double2Int# / float2Int# on x86_32

Brad Clow: I upgraded from GHC 6.6.1 to 6.8.1 and around that time I noticed that the output from an app I am working on changed. I have distilled the code down to the following example that produces different output depending on whether it is compiled with -O2 or not:

main = do
    let (T x) = read "T 3"
    print $ f x
    print $ g x

data T = T Int deriving (Read, Show)

f x = truncate $ 2000 / fromIntegral ((x * 25) + 10)

g :: Int -> Int
g x = f x

(See http://www.haskell.org/pipermail/haskell-cafe/2007-November/034930.html)

The reason is that the code generated for double2Int# by the native code generator does not round correctly. (It's not 100% predictable, I believe, but it'll usually round.)

Trac metadata
Trac field Value
Version 6.8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking