TC 2.0 oddity - me or it ?

Michael J. Eager eager at ringworld.Eng.Sun.COM
Thu Nov 15 20:40:44 AEST 1990


In article <7131 at castle.ed.ac.uk> djm at castle.ed.ac.uk (D Murphy) writes:
>I have a program running on a PC which does its job perfectly BUT which 
>produces a Null pointer assignment message after it has finished. This
>is being caused by something after the last instruction (I tested this
>by adding puts("Last"); just before the closing brace of main() and got
>
>Last
>Null pointer assignment


What is happening is that the message is generated after main
returns.  The actual use of the null pointer is not generating the 
message.

The startup routine keeps a copy of several bytes at the beginning of your
data segment.  When main returns, the startup routine checks to see if
this data has been altered.  In your case, it has, and the message is 
written to stderr.  

You are most likely using an uninitialized pointer and writing to this
memory.  That your program works is luck, and the fact that you do not
overwrite a large amount of data.  

-- Mike Eager



More information about the Comp.lang.c mailing list