Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!sdcrdcf!ism780c!tim From: tim@ism780c.UUCP (T.W."Tim" Smith, Knowledgian) Newsgroups: comp.sys.mac.programmer Subject: Pointer bugs in LightspeedC Message-ID: <9827@ism780c.UUCP> Date: 27 Apr 88 17:22:57 GMT Reply-To: tim@ism780c.UUCP (T.W."Tim" Smith, Knowledgian) Organization: Suction and Pressure Lab, California Institute of Lawsonomy Lines: 30 I found an annoying bug in LightspeedC last week. I had a function that needed to know it's own return address. I tried this: func( dummy ) { unsigned long RetAddr; RetAddr = *(unsigned long *)((char *)&dummy-4); . . . } I Nosy'ed the resultant code and found that LsC had dropped the subtraction of 4 from the pointer! It treated the above expression like this: RetAddr = *(unsigned long *)((char *)&dummy); Changing the expression to this made it work: RetAddr = (unsigned long)&dummy; RetAddr -= 4; RetAddr = *(unsigned long *)RetAddr; This was LsC on a plus. It was version 2.(something less than the version that supports the SE and the II). -- Tim Smith tim@ism780c.isc.com "I don't practice what I preach because I'm not the kind of person I'm preaching to" -- J.R. "Bob" Dobbs