Path: utzoo!attcan!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW C 2.0.2 bug suspected, how do I localize it? Message-ID: <8886@dartvax.Dartmouth.EDU> Date: 14 Jun 88 03:03:12 GMT References: <1215@spar.SPAR.SLB.COM> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Dartmouth College, Hanover, NH Lines: 30 In article <1215@spar.SPAR.SLB.COM> freeman@spar.UUCP (Jay Freeman) writes: > >I now have a strong feeling that the code generated for the original version >of "foo" put "myLong" in a register that was not saved across the call to >"bar", and that "SFGetFile" uses that register. This is a wild guess, but do you perchance have an INIT named "QuickFolder" or something in your system folder? I ran into exactly this problem, and finally found out QuickFolder was using D2, and not restoring it. This is a general problem with Pascal on the Mac: Pascal functions and procedures do not save exactly the same registers as C expects, or as the ToolBox does in many cases. I believe the problem with QuickFolder was that it had a Pascal procedure in it which was patching itself into SFxxxFile somewhere, and the Pascal compiler was not saving the same regs as the Package routine was. This is not the fault of the Pascal compiler, either, since how can it possibly know that it is generating code which will be put in a patch? Another possibility (Heaven forbid!) is that the INIT was written in assembly, and the author simply didn't save the correct registers. I don't think this is a problem with MPW C, I really think you have a defective INIT. I call SFGetFile() all the time from MPW C functions which have scads of auto variables, and never had any problem except for the QuickFolder thing. ********************************************************************* *Earle R. Horton, H.B. 8000, Dartmouth College, Hanover, NH 03755 * *********************************************************************