Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!esosun!ucsdhub!sdcsvax!celerity!jjw From: jjw@celerity.UUCP (Jim ) Newsgroups: comp.lang.c Subject: Re: Disregarding parentheses in C Message-ID: <73@celerity.UUCP> Date: Fri, 24-Apr-87 16:28:08 EST Article-I.D.: celerity.73 Posted: Fri Apr 24 16:28:08 1987 Date-Received: Sun, 26-Apr-87 00:38:48 EST References: <200@m10ux.UUCP> <6378@mimsy.UUCP> <1038@wanginst.EDU> Reply-To: jjw@celerity.UUCP (Jim (JJ) Whelan) Organization: Celerity Computing, San Diego, Ca. Lines: 39 Keywords: C parentheses evaluation order parsing I hesitate to contradict what a standard says about itself but... In article <1038@wanginst.EDU> mckeeman@wanginst.UUCP (William McKeeman) quotes 3j11 document July 9, 1986: >Footnote 15 tells how to imply precedence from the syntax and order of >presentation in the draft standard. > >[begin of quote of Rationale, dated 7 July 1986, section 2.1.2.3, Program >execution.] > > ... A question sometimes asked regarding optimization is, "Is the >rearrangement still conforming if the pre-computed expression might raise a >signal (such as division by zero)?" Fortunately for optimizers, the answer >is "Yes", because any evaluation that raises a computational signal has >fallen into an _undefined_behavior_ (refer to section 3.3) for which any >action is allowable. > >[end of quote] > >[begin comment by McKeeman] > >The only constraint on compiler rearrangements is that the TYPE of the >operands and results not thereby be changed. (emphasis mine) > >[end of comment] The operative paragraph is: > An expression involving more than one occurrence of the same commutative >and associate binary operator (*, +, &, ^, |) may be regrouped arbitrarily, >even in the presence of parentheses, provided the types of the operands or of >the results are not changed by this regrouping. In my opinion, an exception resulting in an "undefined behavior" is a different result from an un-regrouped expression that does not generate an exception and therefore provides a "defined behavior" -- J. J. Whelan