ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/13/13:57:23

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How assign to NULL POINTER
Date: Wed, 13 Nov 1996 09:03:25 -0800
Organization: Alcyone Systems
Lines: 41
Message-ID: <3289FF5D.6C1E38FA@alcyone.com>
References: <9611131456 DOT AA13732 AT emma DOT ruc DOT dk>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ole Winther wrote:

> I where asking about course of "segment violation at pointer " error, while
> running a gcc compiled program. I got the answer that it probaly is a Null
> pointer assignment and I must belive it'sw true, course the "BC" compiled
> program which where running the same code, was also complaining about the
> Null pointer assignment while program end was ended.
> 
> I really dont know how I can assign value's to the NULL pointer, can someone
> describe how this can be done?

"Null pointer assignment" means you're dereferencing a null pointer and
attempting to write to where it's pointing.  This is a bad thing.

That is, 

    int *p = 0;

    *p = 26;

is a null pointer assignment.

Generally intermittent crashes and such are the cause of "dangling pointers"
(sometimes also called null pointer assignment), where the pointer isn't
necessarily a null pointer, but it is not pointing at well-behaved memory.
For instance, 

    int *p;

    *p = 23;

is a dangling pointer assignment; the pointer p is not initialized, and thus
initially contains garbage.  This could be null, or it could be pointing at
some random location in memory.

-- 
                             Erik Max Francis | max AT alcyone DOT com
                              Alcyone Systems | http://www.alcyone.com/max/
                         San Jose, California | 37 20 07 N 121 53 38 W
                                 &tSftDotIotE | R^4: the 4th R is respect
         "But since when can wounded eyes see | If we weren't who we were"

- Raw text -


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