Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!stan!kucharsk From: kucharsk@solbourne.com (William Kucharski) Newsgroups: comp.windows.x Subject: Re: tvtwm patch 5 dumps core Message-ID: <1991May15.190128.6463@solbourne.com> Date: 15 May 91 19:01:28 GMT References: <1991May11.004433.14527@agate.berkeley.edu> <1991May15.094059.8696@nss1.com> Organization: Solbourne Computer, Inc., Longmont, CO Lines: 22 In article <1991May15.094059.8696@nss1.com> mrm@nss1.com (Michael R. Miller) writes: >This is not a correct solution. C compilers are NOT constrained to >resolve the '||' test in any particular order resulting in the test >"!ActiveMenu->entered" possibly being accomplished prior to the >checking of the validity (non-NULLness) of ActiveMenu. This can >still core dump if compiled under some C compilers. Wrong; if your compiler does resolve the second reference it's broken. From page 191 of K&R: "The || operator groups left-to-right. It returns 1 if either of its operands is non-zero and 0 otherwise. Unlike |, || guarantees left-to-right evaluation; moreover, the second operand is not evaluated if the value of the first operand is non-zero." BTW, the same thing (except the second operand is not evaluated if the first argument is 0) applies for the "&&" operator. -- | William Kucharski, Solbourne Computer, Inc. | Opinions expressed above | Internet: kucharsk@Solbourne.COM | are MINE alone, not those | uucp: ...!{boulder,sun,uunet}!stan!kucharsk | of Solbourne... | Snail Mail: 1900 Pike Road, Longmont, CO 80501 | "It's Night 9 With D2 Dave!"