Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!sm.unisys.com!randvax!florman From: florman@randvax.UUCP (Bruce Florman) Newsgroups: comp.sys.mac.programmer Subject: Re: serious code generation bug in Lightspeed C Message-ID: <1858@randvax.UUCP> Date: 17 Jan 89 18:54:36 GMT References: <6275@hoptoad.uucp> <1676@helios.ee.lbl.gov> <6315@hoptoad.uucp> <24012@apple.Apple.COM> Reply-To: florman@rand-unix.UUCP (Bruce Florman) Organization: Rand Corp., Santa Monica, Ca. Lines: 48 In article <24012@apple.Apple.COM> dowdy@Apple.COM (Tom Dowdy) writes: >A subtle bug that is hinted at here effects users of Object Pascal >more often, but can bite others as well: > >If you call a function with a field from a handle based record, or >Object Pascal object, as one of the parameters and the function >or procedure you are calling is in another, unloaded, segment >you will be in for a crash. The MPW 3.0 compilers check for >this condition and warn you about it. I'm not sure that I understand this statement. Are you saying that the following code will crash if Foo and Bar are in different segments, and the segment containing Foo is unloaded when Bar is executed? ------------------------------------------------------------------------ TYPE SomeRecord = RECORD field1, field2 : INTEGER; END; SomeRecPtr = ^SomeRecord; SomeRecHdl = ^SomeRecPtr; FUNCTION Foo(a : INTEGER) : BOOLEAN; BEGIN Foo := a > 37; END; PROCEDURE Bar(srH : SomeRecHdl); BEGIN IF Foo(srH^^.field2) THEN SysBeep(10); END; ------------------------------------------------------------------------ I can see where there would be a problem if Foo's parameter were being passed by reference, or if Foo's result were being assigned to a field of the record, but I don't understand how the code above can cause a problem. Am I just being dense, or what? > Tom Dowdy Internet: dowdy@apple.COM > Apple Computer MS:27Y AppleLink:DOWDY1 > 20525 Mariani Ave UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy > Cupertino, CA 95014 > "The 'Oo-Ah' Bird is so called because it lays square eggs." Bruce Florman florman@rand.org