Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!ringworld.Eng.Sun.COM!eager From: eager@ringworld.Eng.Sun.COM (Michael J. Eager) Newsgroups: comp.lang.c Subject: Re: TC 2.0 oddity - me or it ? Message-ID: <2847@exodus.Eng.Sun.COM> Date: 15 Nov 90 09:40:44 GMT References: <7131@castle.ed.ac.uk> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 24 In article <7131@castle.ed.ac.uk> djm@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