Path: utzoo!attcan!uunet!eplrx7!mcneill
From: mcneill@eplrx7.UUCP (Keith McNeill)
Newsgroups: comp.sources.bugs
Subject: Re: Patch #2 to Pcomm v1.1
Summary: The word according to K&R....
Message-ID: <682@eplrx7.UUCP>
Date: 22 Sep 88 16:24:33 GMT
References: <13900004@osiris.cso.uiuc.edu> <416@quintus.UUCP> <7782@bcsaic.UUCP>
Lines: 39

In article <7782@bcsaic.UUCP>, paula@bcsaic.UUCP (Paul Allen) writes:
> In article <416@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
> >In article <13900004@osiris.cso.uiuc.edu> hood@osiris.cso.uiuc.edu writes:
> >
> >>!   if (*lock_path != NULL && lock_path != NULL) {
> >
> >This only tests whether lock_path is legal *after* trying to use it!
>
> I've now seen a couple postings about this bug, but nobody has got it
> right yet!  What has been missed is that C makes no guarantee about the
> order of expression evaluation.  The only safe way to perform this test
> is using two nested if statements.
>
> I'll be quiet now.
> Paul

WRONG WRONG WRONG...

"Expressions connnected by && or || are evaluated left to right, and evaluation
stops as soon as the truth or falsehood of the result is known." (K&R PG 38)

You seem to have been confused by the fact that "C, like most languages, does
not specify in what order the operands of an operator evaluated." (K&R PG 49)

(FLA..FLA..FLA.....FLAME ON)
Would hate to see your code with all those nested if-statements....
If only you had read the words of the prophets Brian & Dennis.
(FLAME OFF) 

We'll be quiet now.

Keith & Thom

			
-- 
    Keith D. McNeill              |    E.I. du Pont de Nemours & Co.
    uunet!eplrx7!mcneill          |    Experimental Station
    (302) 695-7395                |    P.O. Box 80357
                                  |    Wilmington, Delaware 19880-0357