Mail Archives: djgpp/1996/11/13/13:57:23
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 -