From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11390f,4c42ac518eba0bbe X-Google-Attributes: gid11390f,public X-Google-Thread: 1014db,4c42ac518eba0bbe X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,4c42ac518eba0bbe X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,4c42ac518eba0bbe X-Google-Attributes: gid103376,public From: Ron Natalie Subject: Re: Programming language vote - results Date: 1997/11/26 Message-ID: <347C420A.2B18@sensor.com>#1/1 X-Deja-AN: 292875605 References: <3470EF6E.F74@lysator.liu.se> <64qsf0$ccc@dfw-ixnews11.ix.netcom.com> <347440AD.35DF@idt.net> <65di3v$730$1@news1.ucsd.edu> Organization: Sensor Systems Newsgroups: comp.lang.ada,comp.lang.apl,comp.lang.c,comp.lang.c++ Date: 1997-11-26T00:00:00+00:00 List-Id: William Tanksley wrote: > > > According to the ANSI standard and K&R, as well as universal prior > practice, the boolean logical operators are short-circuiting. This > means that they MUST exectute in order. In fact, this is required > explicitly by ANSI and K&R. The spec calls these sequence points. Furthermore, && and || are required not to execute the right operand if the left side evaluates to false (in the case of and) or true (in the case of or). > The malloc example *probably* has enough parentheses to force it to > work in the right order but the fact is that the code is obscure at > best and wrong at worst. It is also no more efficient when compiled > than the equivalent construct: Assuming to is a pointer, there's nothing wrong with the statement as written by the original poster. PARENS do NOT AFFECT ORDERING in C/C++, they only affect the binding of the operations. > It'll work, so long as the library returns zeroes for nulls. It works no matter what. The constant zero is the null pointer constant. If malloc returns a null pointer regardless of it's machine representation, testing it for equality against an integer zero (or the boolean not) will work.