Skip to content
GitLab
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 5,246
    • Issues 5,246
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 570
    • Merge requests 570
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19411
Closed
Open
Issue created Feb 20, 2021 by Bodigrim@BodigrimDeveloper

fromIntegral (2^64 :: Integer) == (0 :: Natural)

Summary

powModNatural returns a wrong answer.

Steps to reproduce

import Data.Bits
import GHC.Natural

main = print $ powModNatural 0 (fromIntegral n) 2
  where
    n = 1 `shiftL` 64 :: Integer
    {-# NOINLINE n #-}
$ ghc -O1 powmod.hs && ./powmod
[1 of 1] Compiling Main             ( powmod.hs, powmod.o )
Linking powmod ...
1

Expected behavior

Expected answer is 0. Removing NOINLINE, changing fromIntegral to fromInteger, or switching to -O0 all rectify the situation.

Environment

  • GHC version used: 9.0.1

Optional:

  • Operating System: MacOS
  • System Architecture: x64
Edited Feb 21, 2021 by Bodigrim
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking