www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/16/07:56:53

Date: Fri, 16 Aug 1996 13:53:14 +0200 (MET DST)
From: Mark Habersack <grendel AT ananke DOT amu DOT edu DOT pl>
Reply-To: grendel AT ananke DOT amu DOT edu DOT pl
To: Leath Muller <leathm AT gbrmpa DOT gov DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: bug with gcc???
In-Reply-To: <199608140425.OAA01240@gbrmpa.gov.au>
Message-ID: <Pine.NEB.3.95.960816135001.4971D-100000@ananke.amu.edu.pl>
MIME-Version: 1.0

On Wed, 14 Aug 1996, Leath Muller wrote:

>I finally got my code to work, and I have to admit I think it's peculiar as
>to why...
>
>The origal code was something like:
>
>	temp = head_of_list;
>	while (temp->next != NULL)
>		temp = temp->next;
>
>This died a horrible death, and yet when I changed the code to the following:

>Is this a bug with gcc??? Or what??? :|
Nope. It's not a bug. Here's the correct version of you code:
    temp = head_of_list;
    while (temp) /* Or, while( temp != NULL )
      temp = temp->next

The problem was that, when the ->next field was NULL, you were assigning NULL
to temp and then tried to reference the NULL pointer. And that, of course,
caused you code go to hell.

Greetings, Mark

/************************************************************/
/** Maybe it was infatuation or the thrill of a chase?   **/          
/** Maybe you were always beyond my reach and my heart **/
/**   was playing safe?                     ***********/ 
/** But was that love in your eyes I saw, **/
/**   or the reflection of mine?        **/
/** I'll never really know for sure,  **/
/** You never really gave me time!  **/
/** Won't you give me that time?  **/ 
/**          "Cindirella Search" **/
/********************************/
Visit my homepage: http://ananke.amu.edu.pl/~grendel

- Raw text -


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