No sequence points in assignment

Jeffrey Kegler jeffrey at algor2.algorists.com
Wed Sep 20 17:20:23 AEST 1989


Those without a taste for semantic nit-picking should skip the following,
which contains nothing else of value.

karzes> In article <1033 at m3.mfci.UUCP> karzes at mfci.UUCP (Tom Karzes) writes:
diamond> In article <10851 at riks.csl.sony.co.jp> diamond at riks. (Norman Diamond) writes:
dpANS 3.3> In article <1026 at m3.mfci.UUCP> karzes at mfci.UUCP (Tom Karzes) quotes:

dpANS 3.3> Between the previous and next sequence point an object shall have
dpANS 3.3> its stored value modified at most once by the evaluation of an
dpANS 3.3> expression.  Furthermore, the prior value shall be accessed only
dpANS 3.3> to determine the value to be stored.

diamond> Even if the expression contains two assignments to the same
diamond> object?  (As did the example which led to this thread.)  Even
diamond> without the optimizer turned on, the compiler is REQUIRED to
diamond> notice and delete all but one assignment to the same object?
diamond> Wow, a non-optimizing compiler is going to have to do a lot
diamond> of alias checking in order to meet section 3.3.

karzes> This paragraph is merely describing restrictions on the side
karzes> effects a user may have in an expression.

I am glad someone besides me (Norman Diamond) had the same problem reading
those two sentences in 3.3 as I did.  They are ambiguous depending on
whether they are taken to restrict the program or the implementation.
Footnote 31 and Appendix A.6.2 make quite clear that the intention was
to restrict the program, but they are not supposed to be part of the
standard.

It is clear what the dpANS intended to say, and it seems equally clear
that what it intended to say is the only thing that makes sense.
However, I do not believe the standard here says what it intends.

dpANS 1.6> If a "shall" or "shall not" requirement that appears out of
dpANS 1.6> a constraint is violated, the behavior is undefined.  ...
dpANS 1.6> Constraints -- syntactic and semantic restrictions by the
dpANS 1.6> which the exposition of language elements is to be
dpANS 1.6> interpreted."

Are the above two sentences from 3.3 "semantic restrictions", in which
case the burden is on the implementation?  I think so.

The definition of "shall" in 1.6 here is much too hard to interpret.
I think whereever undefined behavior is allowed the standard should
explicitly say so.  This requires only an editorial effort, since
Appendix A.6.2 lists all such cases.
-- 

Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc.
jeffrey at algor2.ALGORISTS.COM or uunet!algor2!jeffrey
1762 Wainwright DR, Reston VA 22090



More information about the Comp.std.c mailing list