Opened 6 years ago

Closed 6 years ago

#5626 closed bug (fixed)

Miscompilation, exception omitted with -O

Reported by: michal.palka Owned by: simonpj
Priority: high Milestone: 7.4.1
Component: Compiler Version: 7.3
Keywords: strictness strict exception miscompilation Cc: michal.palka@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case: codeGen/should_run/5626
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Following program is miscompiled when compiled with -O.

module Main where

wrap x = [x]!!0

f :: [Int] -> a
f a = foldr (\b -> \c -> c) (undefined ()) (a ++ a) 0

main = do
  print $ (f [] :: String)
  print $ wrap $ (f [] :: Int)
  print $ wrap $ (f [] :: (Int, Int, Int, Int))

The result of running it on my machine (Linux x86-64) is following:

zsh: segmentation fault  ./test7

Looking at the Core it seems that instead of the expected undefined a partially-applied function is returned. GHC 7.3.20111022 was used for testing.

Change History (4)

comment:1 Changed 6 years ago by simonmar

Milestone: 7.4.1
Priority: normalhigh

comment:2 Changed 6 years ago by igloo

Owner: set to simonpj

comment:3 Changed 6 years ago by simonmar

Not reproducible with either 7.2.1 or 7.3.20111114 (last night's build), but a slightly older build I had does exhibit the bug (7.3.20111109). I suspect this was fixed by #5475. I'll add a test and close.

comment:4 Changed 6 years ago by simonmar

Resolution: fixed
Status: newclosed
Test Case: codeGen/should_run/5626
Note: See TracTickets for help on using tickets.