2014-04-15 12 views
7

मेरे पास निम्न प्रोग्राम है और यह संकलित नहीं होगा; यह सिर्फ संकलन मुख्य पर फंस गया है। मुझे यकीन नहीं है कि यह क्यों जम जाता है क्योंकि यह या तो एक बग है या मुझे कुछ याद आ रहा है?क्या यह एक जीएचसी बग है?

import qualified Data.Vector.Unboxed as V 

test :: [Int] 
test = V.foldl' unique [] k 
where 
    n = 10000000 
    k = V.generate n (\i -> i `div` 1000 * 1000) 
    unique [] k = [k] 
    unique [email protected](ck:_) k 
     | k == ck = acc 
     | otherwise = k:acc  

main :: IO() 
main = print $ head test 

GHC --make -O3 -Odph -fllvm test.hs

+1

यदि कोई कंपाइलर लटकता है, तो यह स्पष्ट रूप से या तो एक कंपाइलर बग है, या पर्यावरण के साथ कुछ गलत है (या आप सी ++ में मेटा प्रोग्रामिंग कर रहे हैं)। – mydogisbox

+0

संकलन में किस चरण में यह लटका है? आप विशेष चरणों के बाद जीएचसी को रोकने के लिए कह सकते हैं, क्या आप कोर को डंप कर सकते हैं, या यह कहीं और अटक गया है? – bheklilr

+0

पक्षियों को लगता है, लेकिन यह मेरे लिए 'ghc --make test.hs' – Sibi

उत्तर

7

हाँ, मुझे लगता है कि इस बग है: https://ghc.haskell.org/trac/ghc/ticket/5550

-v उपयोग करके, आप देख सकते हैं कि GHC हैंग हो कर SpecConstr अनुकूलन:

ghc-7.6.3 test.hs -O2 -fforce-recomp -v 
Glasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.0.4 
Using binary package database: /nix/store/x5rdp4smhc6q3rxbw4x1akj10z3h0lvg-haskell-env-ghc-7.6.3/lib/ghc-7.6.3/package.conf.d/package.cache 
hiding package Cabal-1.16.0 to avoid conflict with later version Cabal-1.18.1.3 
hiding package QuickCheck-2.6 to avoid conflict with later version QuickCheck-2.7.3 
hiding package binary-0.5.1.1 to avoid conflict with later version binary-0.7.1.0 
wired-in package ghc-prim mapped to ghc-prim-0.3.0.0-d5221a8c8a269b66ab9a07bdc23317dd 
wired-in package integer-gmp mapped to integer-gmp-0.5.0.0-2f15426f5b53fe4c6490832f9b20d8d7 
wired-in package base mapped to base-4.6.0.1-02ac91ff7de681afee6a8fa62f0c87f3 
wired-in package rts mapped to builtin_rts 
wired-in package template-haskell mapped to template-haskell-2.8.0.0-0cee70fbb279a3d93dcc4ec502790a2b 
wired-in package dph-seq not found. 
wired-in package dph-par not found. 
Hsc static flags: -static 
*** Chasing dependencies: 
Chasing modules from: *test.hs 
Stable obj: [] 
Stable BCO: [] 
Ready for upsweep 
    [NONREC 
     ModSummary { 
     ms_hs_date = 2014-04-15 18:43:29 UTC 
     ms_mod = main:Main, 
     ms_textual_imps = [import (implicit) Prelude, 
          import qualified Data.Vector.Unboxed as V] 
     ms_srcimps = [] 
     }] 
*** Deleting temp files: 
Deleting: 
compile: input file test.hs 
Created temporary directory: /tmp/ghc23870_0 
*** Checking old interface for main:Main: 
[1 of 1] Compiling Main    (test.hs, test.o) 
*** Parser: 
*** Renamer/typechecker: 
*** Desugar: 
Result size of Desugar (after optimization) 
    = {terms: 55, types: 44, coercions: 0} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 46, types: 34, coercions: 5} 
Result size of Simplifier iteration=2 
    = {terms: 48, types: 40, coercions: 5} 
Result size of Simplifier = {terms: 48, types: 40, coercions: 5} 
*** Specialise: 
Result size of Specialise = {terms: 48, types: 40, coercions: 5} 
*** Float out(FOS {Lam = Just 0, Consts = True, PAPs = False}): 
Result size of Float out(FOS {Lam = Just 0, 
           Consts = True, 
           PAPs = False}) 
    = {terms: 66, types: 58, coercions: 5} 
*** Float inwards: 
Result size of Float inwards = {terms: 66, types: 58, coercions: 5} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 76, types: 66, coercions: 36} 
Result size of Simplifier iteration=2 
    = {terms: 71, types: 60, coercions: 26} 
Result size of Simplifier = {terms: 71, types: 60, coercions: 26} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 143, types: 113, coercions: 33} 
Result size of Simplifier iteration=2 
    = {terms: 99, types: 79, coercions: 30} 
Result size of Simplifier = {terms: 99, types: 79, coercions: 30} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 120, types: 88, coercions: 26} 
Result size of Simplifier iteration=2 
    = {terms: 90, types: 64, coercions: 16} 
Result size of Simplifier iteration=3 
    = {terms: 88, types: 63, coercions: 16} 
Result size of Simplifier = {terms: 88, types: 63, coercions: 16} 
*** Demand analysis: 
Result size of Demand analysis 
    = {terms: 88, types: 63, coercions: 16} 
*** Worker Wrapper binds: 
Result size of Worker Wrapper binds 
    = {terms: 108, types: 80, coercions: 23} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 100, types: 72, coercions: 13} 
Result size of Simplifier iteration=2 
    = {terms: 91, types: 58, coercions: 9} 
Result size of Simplifier = {terms: 91, types: 58, coercions: 9} 
*** Float out(FOS {Lam = Just 0, Consts = True, PAPs = True}): 
Result size of Float out(FOS {Lam = Just 0, 
           Consts = True, 
           PAPs = True}) 
    = {terms: 93, types: 59, coercions: 9} 
*** Common sub-expression: 
Result size of Common sub-expression 
    = {terms: 93, types: 59, coercions: 9} 
*** Float inwards: 
Result size of Float inwards = {terms: 93, types: 59, coercions: 9} 
*** Liberate case: 
Result size of Liberate case = {terms: 93, types: 59, coercions: 9} 
*** Simplifier: 
Result size of Simplifier iteration=1 
    = {terms: 93, types: 59, coercions: 9} 
Result size of Simplifier = {terms: 93, types: 59, coercions: 9} 
*** SpecConstr: 
Result size of SpecConstr 

तुम भी परीक्षण कर सकते हैं कि -fno-spec-constr या -fno-enable-rewrite-rules का उपयोग कर बनाता है बग गायब हो जाते हैं। इसने इसे नवीनतम जीएचसी (7.8.2) के साथ परीक्षण किया, और यह मुद्दा वहां तय किया गया प्रतीत होता है।

संबंधित मुद्दे