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,410
    • Issues 5,410
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 604
    • Merge requests 604
  • 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
  • #23184
Closed
Open
Issue created Mar 27, 2023 by Andrei Borzenkov@sand-witchDeveloper

Miscompilation of code snippet into <<loop>>

Summary

I found a miscompilation bug. It was fixed in 9.6, but I didn't find the ticket, so it could be accidental fix.

Steps to reproduce

{-# LANGUAGE BangPatterns #-}
import GHC.Magic

main :: IO ()
main = print $ noinline (\x -> sum $ tardisManual [0..x]) 0

tardisManual :: [Int] -> [Int]
tardisManual xs =
  let
    go []     !acc _ = ([], 0)
    go (_:xs) !acc l =
      let (xs', _) = go xs acc l
      in (l:xs', 0)
    (r, l) = go xs True l
  in r
{-# INLINE tardisManual #-}

This code fails with <<loop>>

Expected behavior

It should print 0

Environment

  • GHC version used: all versions from 9.0 to 9.4 fails with <<loop>>, 8.X versions and 9.6 works as expected
Edited Mar 27, 2023 by Andrei Borzenkov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking