sequence points

scott douglass scott at Apple.COM
Sat Jun 30 19:02:58 AEST 1990


In article <1988 at mcrware.UUCP> jejones at mcrware.UUCP (James Jones) writes:
>Suppose one has an expression of the form
>
>	func1(<argument list>) + func2(<argument list>)
>
>Now, there are two sequence points here, namely those occurring after the
>evaluation of the argument list of each of the functions and before the
>call.  On the other hand, one can't count on which of the two functions will
>be called first.

A closely related question* that has been bothering me for a couple
months is:
    Do func1 and func2 have to be executed atomically (that
    is, one completely before the other but only the compiler
    knows which) or can they be executed in parallel?

Stating this question a different way:
    Where in the standard does it say that the next sequence point
    will be in the same function as the previous one?  (Assuming that
    there is another sequence point in this function.)

In fact:
    Where in the standard does it say which is the next sequence point
    after the one just before a function call?  Can you prove that any
    of the sequence points in the called function will, in fact, be
    reached?

In general, the standard seems to leave the question of "Which is the
next sequence point?" undefined so there is only a partial ordering on
sequence points.  One of the most restrictive quotes is this somewhat
vauge one in section 3.6 Statements:
    "Except as indicated, statements are executed in sequence."

I'm working from a Dec 88 draft.

Obviously, to me anyway, you do want a guarentee that called functions
will be (as if) executed.  Also it seems likely to break quite a bit
of existing code if the two functions may be run in parallel.

Thanks for your help.

	--scott douglass (scott at apple.com)

p.s.  If the answer to this is "send it to the committe for interpret-
ation", please give me explicit instructions on how to do it.

(*) This actually arose from a difference of opinion I have with CFront
about it's implementation of inlining.  I botched a posting to
comp.lang.c++ trying to get an answer to my question in it's original
form.  Since the C++ answer depends on the answer to this question
I'm trying again here.  I've also read P.J. Plaugher's article "Sequence
Points and Parallelism" in The Journal of C Language Translation but
unfortunately it didn't address this question.  I've even asked Bjarne
and he didn't give me an answer.  You people are my only hope.
-- 
	--scott douglass	scott at apple.com



More information about the Comp.std.c mailing list