Function Argument Evaluation

Blair P. Houghton bhoughto at hopi.intel.com
Wed Mar 27 16:16:29 AEST 1991


In article <1991Mar26.181821.22912 at cs.ucla.edu> jon at maui.cs.ucla.edu (Jonathan Gingerich) writes:
>Thanks Blair,(and everyone else contributing)

You're welcome.

>your point perfectly well.  My question remains 'Does "the value
>of the left operand after the assignment" mean "immediately after" or 
>"sometime after, before the next sequence point"?'

Sequence points (q.v., if you have the Standard handy) define what
"after" is.  Machines have a tendency to have propagation delays
for register transfers and whatnot, so it's not possible for
"immediately" to exist; plus, this is a high-level language, and
it will be translated into any number of object-level representations.

"Before" an operation is a sequence point.  "After" an
operation is the next sequence point.  There is no
"after the operation but before the sequence point."

>A second question is whether the expression (print statement) is defined to
>begin with, which would render the above question meaningless, unless it
>can be reconstructed with a volitile variable.  I had thought Doug was
>claiming the statement was not undefined, but I may have misinterpreted
>his posting.

You win the Convoluted Paragraph Of The Quarter Prize.
I had to solve it to figure out what you could possibly
be saying without also being totally bats:

If you mean "is the function call guaranteed to occur
regardless of the order of evaluation of the arguments,"
then yes, that is correct.  Something will be printed,
using the format passed and to the file specified, if their
values are not somehow dependent on the order of
evaluation.  (Here they are, respectively, a string constant
(the format), and implied (stdout, the place to which
printf(3) prints), so they aren't dependent on a couple of
assignments and dereferences).  This is true of all
functions, not just predefined library routines.

To clarify: the machine _must_ evaluate the expressions and
call the function; the word "unspecified" merely says that
the Standard refuses to insist on a specific order.

If the Standard says "the behavior is undefined," then you
can start taking bets as to what will happen next.

				--Blair
				  "Code is to time what
				   topology is to geometry."



More information about the Comp.std.c mailing list