Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jul 2000 11:51:53 +0100
From:      Mark Ovens <marko@freebsd.org>
To:        hackers@freebsd.org
Subject:   ANSI compliance, gcc(1) and FreeBSD
Message-ID:  <20000729115153.C236@parish>

next in thread | raw e-mail | index | archive | help
Apologies if this is the wrong list for this question but it seems the
best place to get a *definitive* answer.

In the ANSI Standard (K&R 2e, A7.14 & A7.15) it states that, in the
case of the ``&&'' operator, the right operand is evaluated only if
the left operand evaluates to non-zero, and, for ``||'', the right
operand is evaluated only if the left operand evaluates to zero.

My questions are: does gcc(1) honour this, and is it permitted to rely
on this behaviour in FreeBSD (base system)?, e.g., would the following
be acceptable if we wanted to guarantee that foobar was set to BAR
*only* if FOO was unset or NULL?

   char *foobar;

   if ((foobar = getenv("FOO")) != NULL || (foobar = getenv("BAR")) != NULL)

I couldn't find the answer in style(9).

Please Cc: me as I'm not subscribed to -hackers.

TIA

-- 
  If I buy a copy of WinDelete, and it doesn't delete Windows,
  am I entitled to my money back?
________________________________________________________________
51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
mailto:marko@freebsd.org                http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000729115153.C236>