Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usenet!ogicse!intelhf!ichips!inews!bishop!bhoughto From: bhoughto@bishop.intel.com (Blair P. Houghton) Newsgroups: comp.std.c Subject: Re: More Re: Function Argument Evaluation argument Message-ID: <3768@inews.intel.com> Date: 11 Apr 91 00:45:30 GMT References: <1991Apr8.191009.24897@cs.ucla.edu> <3731@inews.intel.com> <1991Apr10.191853.4604@cs.ucla.edu> Sender: news@inews.intel.com Organization: Intel Corp, Chandler, AZ Lines: 57 In article <1991Apr10.191853.4604@cs.ucla.edu> jon@maui.cs.ucla.edu (Jonathan Gingerich) writes: >In article <3731@inews.intel.com> bhoughto@nevin.intel.com (Blair P. Houghton) writes: >>In article <1991Apr8.191009.24897@cs.ucla.edu> jon@maui.cs.ucla.edu (Jonathan Gingerich) writes: >>>Earlier I claimed: >>> printf("%d %d\n", f(...v...), f(...v++...)) >>[was unspecified not undefined] >> >>However, the first usage of `v' has no side effects. >>It can be evaluated regardless of sequence points >>other than the one for the leftward call to f(). >>The value for `v' in the leftward call is indeterminate. > >You are correct as far as you go. But v and v++ can both be evaluated before >either s.p. associated with the application of f()'s and because v is both >read and written in separate actions it's undefined. Okay, make them both v++. Now it's definite that the sequence must be: v++, corresponding s.p., v++, corresponding s.p. though which v++ and corresponding s.p. come first is still unspecified. Doug (or was it Guy?) once made the point about parsing of tokens that maximal munch doesn't hold, rather it is the parsing that is true to the syntax that holds. I think that here a similar situation exists. It's possible to create only two orderings of the evaluations and sequence points in f( g(v), h(v++) ) SUCH THAT the statement is NOT "undefined", and they are v, s.p.(g), v++, s.p.(h) v++, s.p.(h), v, s.p.(g) and the compiler should produce one of these orderings. I.e., if it's possible to avoid undefined behavior by application of sequence points that are defined to exist, then they should be so applied. (Note that the side effects don't force placement of the sequence points, here. The same thing would happen if `v++' were replaced by `v' in both arguments.) I believe that this is what the standard mandates; but it may be the opposite: that if there is ANY way to produce undefined behavior by pushing around the unanchored sequence points, then the behavior should be undefined. --Blair "But then, I go through red lights at 3 a.m. if there's no cross-traffic, too..."