Patch #2 to Pcomm v1.1

Keith McNeill mcneill at eplrx7.UUCP
Fri Sep 23 02:24:33 AEST 1988


In article <7782 at bcsaic.UUCP>, paula at bcsaic.UUCP (Paul Allen) writes:
> In article <416 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
> >In article <13900004 at osiris.cso.uiuc.edu> hood at 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



More information about the Comp.sources.bugs mailing list