Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.c Subject: Re: Is this valid C? Date: Fri, 03 Mar 2017 12:57:22 +0000 Organization: A noiseless patient Spider Lines: 39 Message-ID: <87fuiuldql.fsf@bsb.me.uk> References: <97ad8e6e-6ed3-474a-9c77-dbf3a11e3c93@googlegroups.com> <87lgsmleh9.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="daac0805028715f3f2958ec41815e0d4"; logging-data="23319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182V7EcFTl2EbQxPbhBovI5gmA+PJsyvj4=" Cancel-Lock: sha1:DI9H9dxcl1FzCwzeOE1owen9oHU= sha1:FPU48pYO+D5Z6vwOsmIuKWSrONU= X-BSB-Auth: 1.1e09ccc3c49fde95eb0d.20170303125722GMT.87fuiuldql.fsf@bsb.me.uk Xref: csiph.com comp.lang.c:105350 Richard Heathfield writes: > On 03/03/17 12:41, Ben Bacarisse wrote: >> David Brown writes: >> >>> On 02/03/17 21:54, James Kuyper wrote: >>>> Jerry's uncharacteristic silence has given me some time to think about >>>> this issue more carefully. The idea that operator precedence and >>>> associativity always determine the order of evaluation of C expressions, >>>> with expressions with a high precedence always being >>>> evaluated first, and associativity being used to break ties between >>>> expressions with the same precedence is very popular, and has been >>>> around for a very long time. Jerry didn't invent it, not by a long >>>> shot, but I need a simple name for this rule, so I'll call it the >>>> "Stuckle rule" in honor of Jerry Stuckle. >>>> >>> >>> (I snipped the rest of your detailed and informative post, simply to >>> save space.) >>> >>> Would it be fair to say that if you have an expression where no >>> sub-expression has any side effects (no volatile accesses, ++ operators, >>> assignment operators, etc., and only "pure" function calls) then the >>> Stuckle rule will apply? If you have "x && y" and "y" has no side >>> effects, then it makes no difference to the outcome of the program >>> whether y (or its sub-expressions) is evaluated, even if x evaluates >>> to 0. >> >> It depends on what you mean by saying that the rule will apply. > > Well, it never *actually* applies. But there are circumstances in > which the implementation may behave "as if" it applies. And, curiously, you cut the very next sentence where I said exactly that. :-( -- Ben.