[comp.lang.c] MSC and CodeView Do Not Agree

david@wubios.wustl.edu (David J. Camp) (08/02/89)

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@wubios.wustl                ^      Mr. David J. Camp
Internet: david%wubios@wucs1.wustl.edu    < * >    Box 8067, Biostatistics
uucp:     uunet!wucs1!wubios!david          v      660 South Euclid
Washington University (314) 36-23635               Saint Louis, MO 63110