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 by Andrei Borzenkov