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,863
    • Issues 4,863
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 458
    • Merge requests 458
  • 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
  • #186
Closed
Open
Created Oct 06, 2003 by nobody@trac-nobody

Bad sparc Int64 code via NCG with -O

On sparc machines ( sparc-sun-solaris2.6,
sparc-unknown-openbsd ) testsuite tests exercising
Int64 code are broken when compiled the optasm way.
This includes the arith011 test and the enum02 test,
possibly others. Trivial Int64 code will produce
erroneous results. Turning off optimisation, or
compiling via C, will generate correct code. 

Some examples.. 

This one comes from enum02:

  import Int
  main = do print $ pred (1 :: Int64)

$ ./a.out 
  4294967295

which is UINT_MAX...
And from arith011, this generates incorrect results:

  import Int
  main = do print $ take 10 [ (0::Int64), toEnum 2 .. ]

on x86:
   [0,2,4]
on sparc:
   [0,8589934592,17179869184]

which is 2 * (UNIT_MAX + 1), and then twice that.
This erroneously generates an infinte sequence, filling
up /usr on my system before I realised what happened:

  import Int
  main = do print [ (0::Int64) .. toEnum 2 ]

-- Don Stewart
Edited Mar 09, 2019 by Simon Marlow
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking