Patch #2 to Pcomm v1.1
Brandon S. Allbery
allbery at ncoast.UUCP
Fri Sep 30 10:44:17 AEST 1988
As quoted from <7782 at bcsaic.UUCP> by paula at bcsaic.UUCP (Paul Allen):
+---------------
| 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:
| >>This patch will fix the problem that some people are having with
| >>seqmentation faults (although I'm not convinced the problem isn't
| >>in their compiler).
| >
| >It isn't. It's the famous *NULL bug.
| >
| >>! if (*lock_path != NULL && lock_path != NULL) {
|
| 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.
+---------------
C makes no guarantee about the order of expression evaluation IN GENERAL.
However, it DOES guarantee the evaluation order of && and ||, as they are
intended not to evaluate the expression on the right of the expression on
the left is sufficient to determine the value of the compound expression
(i.e. for "&&" the LHS is zero, for "||" the LHS is non-zero). Check out
K&R, Appendix A, sections 7.11 (&&) and 7.12 (||).
++Brandon
--
Brandon S. Allbery, uunet!marque!ncoast!allbery DELPHI: ALLBERY
For comp.sources.misc send mail to <backbone>!sources-misc
comp.sources.misc is moving off ncoast -- please do NOT send submissions direct
ncoast's days are numbered -- please send mail to ncoast!system if you can help
More information about the Comp.sources.bugs
mailing list