delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/16/05:40:45

From: Weiqi Gao <weiqigao AT a DOT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: question about if statements!
Date: Thu, 15 Jul 1999 19:53:28 -0500
Organization: CRL Network Services
Lines: 24
Message-ID: <378E8288.3A8376BF@a.crl.com>
References: <19990715204430 DOT 18320 DOT rocketmail AT web105 DOT yahoomail DOT com> <7mlk0u$8aj AT dfw-ixnews14 DOT ix DOT netcom DOT com>
NNTP-Posting-Host: a116007.stl1.as.crl.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.0.36 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Marp wrote:
> 
> Mohamed Saad <bazramit AT yahoo DOT com> wrote in message
> news:19990715204430 DOT 18320 DOT rocketmail AT web105 DOT yahoomail DOT com...
> >     does djgpp continue to evaluate an expression of
> > an if statement even if the result is readily
> > available?
> >     i.e.  consider this...
> >     if (0&&dummy1)
> >        statement here;
> >
> >     will it evaluate dummy1??
> 
> No. As a shortcut (for speed) if the left side of the && operator is false,
> the right side won't be tested. Similarly, with the || operator, if the left
> side is true, the right side won't be tested. I think you can safely rely on
> this behavior for all C and C++ compilers, but I'm not absolutely sure of
> that.

This is the standard behavior.

-- 
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


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