C compiler weirdness?

Mark Bartelt sysmark at aurora.physics.utoronto.ca
Sat Apr 13 10:18:56 AEST 1991


In article <97139 at sgi.sgi.com> davea at quasar.UUCP (David B.Anderson) writes:

| Since Mark Bartelt claims that the compiler is wrong, I'll step up to its
| defense (I do not claim that the compiler version used is ANSI C):
|
| ANSI C: 3.3.2.2, page 42. line 20.
| ``The order of evaluation of the function designator, the arguments,
| and subexpressions within the arguments is unspecified, but there is
| a sequence point before the actual call.''
|
| The Standard does not say whether the sequence point is before or
| after the evaluation of the function designator.
|
| The following is thus _a_ legal sequence:
|         evaluate arguments (none in the case above)
|         sequence point (arguments evalation complete)
|         evaluate function designator
|         call function
|         increment pc
|         statement sequence point
|
| So IMO our code generation is legal in this case.  (case dismissed :-)

Hmm...  Interesting interpretation.  But ...  I *think* (and though I feel
reasonably proficient in C, I nonetheless lay no claim to being in a class
with, say, Henry Spencer, let alone dmr or bwk) that in this case the

|         evaluate function designator

*includes* the incrementing of pc.  Observe that the sequence

	note the value of the operand
	increment the operand

is, in its entirety, part of the semantics of the postfix ++ operator.
At least, that's *my* interpretation of what the standard says.  Maybe
we should cross-post this to comp.lang.c (which would generate all sorts
of comments, most of them bogus), or forward the discussion to dmr and
bwk, and see whether either of them care to provide a definitive answer.

Mark Bartelt                                               416/978-5619
Canadian Institute for                            mark at cita.toronto.edu
Theoretical Astrophysics                          mark at cita.utoronto.ca



More information about the Comp.sys.sgi mailing list