GHC loops on compiling with optimizations
|Reported by:||noschinl||Owned by:|
|Operating System:||Linux||Architecture:||x86_64 (amd64)|
|Type of failure:||Compile-time crash||Test Case:|
|Related Tickets:||Differential Rev(s):|
When compiling the snippet below with optimizations enabled (i.e. ghc -O test.hs), GHC does not seem to terminate. This happens with at least 7.0.3 and 7.0.4. Without optimizations, it builds fine.
data A = A Int class C a where fromHsk :: C a => a -> Int instance C Int where fromHsk = fromHsk instance C A where fromHsk (A s) = fromHsk s main = undefined
When building this example with GHC 6.12.4, it fails with a complaint about the bogus type constraints in the declaration of fromHsk:
test.hs:3:0: All of the type variables in the constraint `C a' are already in scope (at least one must be universally quantified here) (Use -XFlexibleContexts to lift this restriction) When checking the class method: fromHsk :: (C a) => a -> Int In the class declaration for `C'
After removing these unneeded constraint (i.e. changing the declaration of fromHsk to fromHsk :: a -> Int, the snippet above builds even with GHC 7.0.4 and optimizations.