Article View: comp.std.c
Article #4425Re: On sequence points and evaluation order
From: Tanmoy Bhattacharya
Date: Wed, 06 Dec 1995 05:17
Date: Wed, 06 Dec 1995 05:17
61 lines
3542 bytes
3542 bytes
--text follows this line-- In article <1995Dec6.000503.6676@sq.com> msb@sq.com (Mark Brader) writes: <snip> To the question: > > > Is `i + (f(),i+i)' well defined? Chris Volpe (volpe@ausable.crd.ge.com) writes: > It must yield one of two values, in an unspecified way, depending on which > of the two operands of the top-level "+" is evaluated first. (I've lost > some context here, but I assume f() modifies i.) I wouldn't call this > "well-defined", but it does not invoke undefined behavior either. I agree with everything here and, I believe, in the rest of Chris's long article, *except* the implication that one of the two operands of the top-level + must be evaluated first. I don't think Chris really meant to make that implication. The evaluation sequence f() left-hand i right-hand i right-hand + top-level + is one of the possibilities, and the left-hand operand of the top-level + is evaluated within the time that the right-hand operand is being done. My question, which Chris was responding to, was whether the the i that is the left operand of the top-level +, henceforth called the top-level i, can be evaluated interleaved with the evaluation of f() (Remember, f() contains a i=1). If it can, then there is a possible sequence of evaluation where i is both modified (in f) and accessed (top-level i) without intervening sequence points. I do not have an opinion: how could I? As an ordinary user of the language, all I can pray for is that the committee does not decide that even this interleaving is prohibited by the panacea of `statements are executed in sequence' :-( The issue of `f()+f()' is different: there one is talking of two statements from two functions. Here we are talking about part of an expression in the caller interleaving with evaluation of a statement in f. In fact in `f()+f();', though the two operands of the + can be interleaved, wasn't the informed opinion last time that _none_ of the statements of one f can be evaluated before _any_ of the statements of the other f, whatever effect that may have on optimization, though which f is called first is indeterminate (Am I misremembering?). All this to satisfy the _unsatisfiable_ edict of `statements are evaluated in sequence': after all `f()+f();' is a statement --- is it done before or after the statements comprising f? Cheers Tanmoy -- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242) Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544 Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>, <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/ internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html> fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<TANMOY.95Dec5221739@qcd.lanl.gov>Path:
arc1-ca.pugleaf.net!newshost.lanl.gov!tanmoyReferences:
<49l428$od0@bolverk.cs.cornell.edu> <49ojjp$hsm@newshost.lanl.gov> <49qiu7$25h@natasha.rmii.com> <49v3ii$nve@rdsunx.crd.ge.com> <1995Dec6.000503.6676@sq.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newshost.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.std.c Subject: Re: On sequence points and evaluation order Date: 06 Dec 1995 05:17:39 GMT Organization: Los Alamos National Laboratory Message-ID: <TANMOY.95Dec5221739@qcd.lanl.gov> References: <49l428$od0@bolverk.cs.cornell.edu> <49ojjp$hsm@newshost.lanl.gov> <49qiu7$25h@natasha.rmii.com> <49v3ii$nve@rdsunx.crd.ge.com> <1995Dec6.000503.6676@sq.com> NNTP-Posting-Host: qcd.lanl.gov Mime-Version: 1.0 Content-Type: text In-reply-to: msb@sq.com's message of Wed, 6 Dec 1995 00:05:03 GMT