tim@ism780c.UUCP (T.W."Tim" Smith, Knowledgian) (04/28/88)
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