Hi,
this turned out to be a bug in the Hugs internals & not how 'foreign label' was implemented per se. A fix has been checked into the CVS repository, so the anonymous CVS should mirror it sometime within the next 24 hours.
Many thanks for reporting the problem.
--sigbjorn
I've tried the latest CVS version and make sure! Thanks! But I found that my runhugs seemed to ignore finalizer... ------------------------------- extern void *newObj(void) { void *obj; obj = malloc(1); printf("obj is born.\n"); return obj; } extern void delObj(MyInt obj) { printf("obj dies.\n"); free(obj); } module Main(main) where import Foreign foreign label "ForeignObj" "delObj" delObj :: Addr foreign import "ForeignObj" "newObj" newObj :: IO Addr main = newObj >>= (\obj -> makeForeignObj obj delObj >> putStr "obj is alive.") ------------------------------- Hugs prints: obj is born. obj is alive. obj dies. runhugs prints: obj is born. obj is alive. How does yours work?