Compiling GreenCard generated programs does not always work on HP-UX.
The following program (a short version of some GreenCard output)
demonstrates the problem:

-- Main.hs ----------------------------------------------------------
import Addr

main :: IO ()
main = do gc_result <- _casm_ ``do {static struct {void *res1;} gc_result;
                                    gc_result.res1 = (void *)malloc(%0);
                                    %r = &gc_result;} while(0);'' (1234::Int)

          res1 <- _casm_ ``do {%r = ((struct {void *res1;}*) %0)->res1;} while(0);'' 
(gc_result :: Addr)
          print (res1::Addr)
---------------------------------------------------------------------

panne@rimatara: > ghc-3.01 -fglasgow-exts Main.hs
ghc-3.01: module version changed to 1; reason: no old .hi file
Funny global thing?: gc_result___30
panne@rimatara: > ./a.out 
Bus error (core dumped)


Note the warning from the mangler. If the "static struct" is changed to
"struct" everything works fine, without a warning and without a core
dump. Is this a bug in GreenCard or in the mangler? What is the intent
of the "static" modifier? I can't see a reason for it, but I may be wrong.

-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne

Reply via email to