www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/13/11:11:33

Date: Wed, 13 Nov 1996 17:52:46 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Ole Winther <owsim AT ruc DOT dk>
Cc: djgpp AT delorie DOT com
Subject: Re: How assign to NULL POINTER
In-Reply-To: <9611131456.AA13732@emma.ruc.dk>
Message-Id: <Pine.SUN.3.91.961113174415.5516D-100000@is>
Mime-Version: 1.0

On Wed, 13 Nov 1996, Ole Winther wrote:

> I really dont know how I can assign value's to the NULL pointer, can someone
> describe how this can be done?

The most frequent case is when you declare a pointer which is a global 
variable (and is therefore initialized to zero even if you didn't give it 
any value), then use it before assigning any value to it.  Example:

	char *ptr;   /* will be initialized to zero by the linker */

	void myfunc(void)
	{
	  char c = *ptr;  /* this will crash your program under DJGPP */
	}

The simplest way to catch these errors is to run your program until it 
crashes, then run symify.  It will add filenames and source line numbers 
to the stack dump.  You should then run your program under a debugger, 
put a breakpoint at the line which crashed (this is the uppermost of the 
lines printed by `symify') and when that breakpoint is hit, examine the 
pointers which that line is using to look for the pointer(s) which have 
zero or garbled values.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019