delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/09/05:05:38

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q] expression evaluation order
Date: Fri, 08 Aug 1997 11:35:13 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 22
Message-ID: <33EB0471.2C0F@cs.com>
References: <97Aug8.112626gmt+0100 DOT 17059 AT internet01 DOT amc DOT de>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp208.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris Croughton wrote:
> 
> One of the most common uses of this is in testing array
> elements, as in:
> 
>   if (i >= 0 && i < 10 && a[i] != x)
>     ...

And the second most common is probably to examine pointers for NULL
values before dereferencing them, as in:

if ( ptr != NULL && ptr->value == x )
    ...

And this too would break if the compiler did not evaluate left-to-right.

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |     mailto:fighteer AT cs DOT com      |
| Proud owner of what might one   |   http://www.cs.com/fighteer    |
| day be a spectacular MUD...     | Plan: To make Bill Gates suffer |
---------------------------------------------------------------------

- Raw text -


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