MSC and CodeView Do Not Agree
David J. Camp
david at wubios.wustl.edu
Wed Aug 2 21:49:30 AEST 1989
Please reply to me directly, since I do not have time to read this
newsgroup. I am using Microsoft C and the CodeView debugger. I am
trying to write some code to detect if absolute location zero is
non-zero. I know MSC does this for you automatically when you exit, but
I want to check within my code.
I wrote a statement like: if (* ((char *) 0L)) bugcheck ();
While tracing it with the debugger, it takes the branch and calls
bugcheck. I use the debugger to look directly at location zero
using '? * ((char *) 0L)' and it prints 0! I tried various forms of this
syntax, all with the same result, until finally I tried
'? ((char *) 0L) [0]' which returned a non-zero result. To my
amazement, it was not the same value as printed out by the bugcheck()
program. The code looks like this:
void bugcheck ()
{
fprintf (stderr, "Location zero has changed: %d\n", * ((char *) 0L));
* ((char *) 0L) = '\0';
}
Why does this happen? Is CodeView really looking at location zero? Is
my program really looking at location zero?
I want it to observe the location that would be trashed if someone
assigned via a NULL pointer.
Thank you for any help. -David-
--
Bitnet: david at wubios.wustl ^ Mr. David J. Camp
Internet: david%wubios at wucs1.wustl.edu < * > Box 8067, Biostatistics
uucp: uunet!wucs1!wubios!david v 660 South Euclid
Washington University (314) 36-23635 Saint Louis, MO 63110
More information about the Comp.lang.c
mailing list