[GHC] #1973: non-exhaustive pattern in getSRTInfo

GHC trac at galois.com
Tue Dec 11 23:02:04 EST 2007


#1973: non-exhaustive pattern in getSRTInfo
-------------------------+--------------------------------------------------
    Reporter:  darinm    |       Owner:         
        Type:  bug       |      Status:  new    
    Priority:  normal    |   Milestone:         
   Component:  Compiler  |     Version:  6.8.1  
    Severity:  normal    |    Keywords:         
  Difficulty:  Unknown   |    Testcase:         
Architecture:  Unknown   |          Os:  MacOS X
-------------------------+--------------------------------------------------
 Here is the code I am attempting to execute:

 {{{
 res :: CoreBind
 defaultCodeGen :: [StgBinding] -> IO [Cmm]

 coreToStg mainPackageId [res] >>= defaultCodeGen >>= mapM_ (GHC.printDump
 . GHC.ppr)
 }}}

 defaultCodeGen makes a call to GHC's codeGen.

 When I try to run coreToStg, I get the following error:

 {{{
 *** Exception: codeGen/CgUtils.hs:(993,2)-(1009,60): Non-exhaustive
 patterns in case
 }}}

 Looking at getSRTInfo and the SRT data type, it looks like the SRTEntries
 data constructor for SRT is never matched.  From the comment in the SRT
 data type, it sounds like this entry is generated precisely by the
 coreToStg function.

 {{{
 getSRTInfo :: FCode C_SRT
 getSRTInfo = do
   srt_lbl <- getSRTLabel
   srt <- getSRT
   case srt of
     -- TODO: Should we panic in this case?
     -- Someone obviously thinks there should be an SRT
     NoSRT -> return NoC_SRT
     SRT off len bmp
       | len > hALF_WORD_SIZE_IN_BITS || bmp == [fromIntegral srt_escape]
       -> do id <- newUnique
             let srt_desc_lbl = mkLargeSRTLabel id
             emitRODataLits srt_desc_lbl
              ( cmmLabelOffW srt_lbl off
                : mkWordCLit (fromIntegral len)
                : map mkWordCLit bmp)
             return (C_SRT srt_desc_lbl 0 srt_escape)

     SRT off len bmp
       | otherwise
       -> return (C_SRT srt_lbl off (fromIntegral (head bmp)))
                 -- The fromIntegral converts to StgHalfWord
 }}}

 {{{
 data SRT = NoSRT
          | SRTEntries IdSet
                 -- generated by CoreToStg
          | SRT !Int{-offset-} !Int{-length-} !Bitmap{-bitmap-}
                 -- generated by computeSRTs
 }}}

 If necessary I can package up some code that can be run to reproduce this
 bug, but perhaps there is a simpler answer first.  Maybe I'm doing
 something in the wrong order in the code generation stuff.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1973>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list