delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/15/18:00:39

From: "Marp" <Marp AT 0 DOT 0 DOT 0 DOT 0>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: question about if statements!
Date: Thu, 15 Jul 1999 17:32:10 -0400
Organization: Netcom
Message-ID: <7mlk0u$8aj@dfw-ixnews14.ix.netcom.com>
References: <19990715204430 DOT 18320 DOT rocketmail AT web105 DOT yahoomail DOT com>
NNTP-Posting-Host: prn-nj3-12.ix.netcom.com
X-NETCOM-Date: Thu Jul 15 4:32:14 PM CDT 1999
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Lines: 18
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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;
>
>     well 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.


- Raw text -


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