Opened 9 years ago

Closed 9 years ago

#2543 closed bug (duplicate)

Nested SPECIALIZEd functions cause error: "Symbol _BadUTF8_zdf1_closure already defined."

Reported by: judah Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.9
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The utf8-string package (in particular, the module Code.Binary.UTF8.Generic) does not compile under ghc-6.9.20080825.

I tried stripping down that module and believe the problem occurs when a SPECIALIZEd function calls another SPECIALIZEd function:

{-# LANGUAGE FlexibleInstances #-}
module BadUTF8 where

import Data.Word

class UTF8Bytes b where

instance UTF8Bytes [Word8] where

{-# SPECIALIZE myfoldr :: (Char -> a -> a) -> a -> [Word8]      -> a #-}
myfoldr :: UTF8Bytes b => (Char -> a -> a) -> a -> b -> a
myfoldr _ x _ = x

{-# SPECIALIZE toString :: [Word8] -> String #-}
toString :: UTF8Bytes b => b -> String
toString bs = myfoldr (:) [] bs

Compiling using ghc-6.9.20080825 without -O, or ghc-6.8.3 with or without -O, does not produce an error. However, ghc-6.9.20080825 with optimization produces:

judah-jacobsons-computer:tmp judah$ ~/tmp/ghc-stage/bin/ghc --make -O BadUTF8.hs
[1 of 1] Compiling BadUTF8          ( BadUTF8.hs, BadUTF8.o )

    FATAL:Symbol _BadUTF8_zdf1_closure already defined.

Change History (1)

comment:1 Changed 9 years ago by simonpj

difficulty: Unknown
Resolution: duplicate
Status: newclosed

Dup of #2520. Thanks for another test case.


Note: See TracTickets for help on using tickets.