#1255: UNPACKing a !Foo with newtype Foo = (Ptr Foo) causes the impossible
-------------------------+--------------------------------------------------
    Reporter:  rashakil  |       Owner:                          
        Type:  bug       |      Status:  new                     
    Priority:  normal    |   Milestone:                          
   Component:  Compiler  |     Version:  6.6                     
    Severity:  normal    |    Keywords:  UNPACK unbox newtype Ptr
  Difficulty:  Unknown   |    Testcase:                          
Architecture:  x86       |          Os:  Linux                   
-------------------------+--------------------------------------------------
Here is the code that causes the error.  The strictness annotation and the
 unboxing of the field is necessary to cause the error.  Experimentation
 shows that the error happens regardless of the number of named fields.  I
 first found this when I tried using "{{{:: {-# UNPACK #-} !X.GC}}}"
 somewhere.

 {{{
 {-# OPTIONS_GHC -funbox-strict-fields #-}

 module Foo where

 import Foreign.Ptr


 newtype  Bar        = Bar (Ptr Bar) -- Must be Bar inside.

 data  Gah           = Gah { baaz  :: !Bar }

 -- Alternately, disable -funbox-strict-fields and use {-# UNPACK #-},
 -- and the impossible still happens.
 }}}

 Here's the error message.

 {{{
 $ ghc --make Foo -v
 Glasgow Haskell Compiler, Version 6.6, for Haskell 98, compiled by GHC
 version 6.6
 Using package config file: /usr/lib/ghc-6.6/package.conf
 wired-in package base mapped to base-2.0
 wired-in package rts mapped to rts-1.0
 wired-in package haskell98 mapped to haskell98-1.0
 wired-in package template-haskell mapped to template-haskell-2.0
 Hsc static flags: -static
 *** Chasing dependencies:
 Chasing modules from: Foo.hs
 Stable obj: []
 Stable BCO: []
 compile: input file Foo.hs
 Created temporary directory: /tmp/ghc3424_0
 *** Checking old interface for main:Foo:
 [1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
     Result size = 0
 *** Simplify:
     Result size = 0
 *** Tidy Core:
 *** Deleting temp files:
 Deleting: /tmp/ghc3424_0/ghc3424_0.s
 Warning: deleting non-existent /tmp/ghc3424_0/ghc3424_0.s
 *** Deleting temp dirs:
 Deleting: /tmp/ghc3424_0
 ghc-6.6: panic! (the 'impossible' happened)
   (GHC version 6.6 for i386-unknown-linux):
         dataConWorkId main:Foo.Bar{d rfa}

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1255>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to