Re: Sequence points



spinoza1111 said:

...are defined in ISO/TEC 9899:TC2 committee draft-May 6 2005

They have been in the Standard since the Standard first appeared in 1989,
almost twenty years ago.

, and
yes, preincrement and postincrement is delayed until the sequence
point,

No, you still don't understand sequence points. Preincrement and
postincrement, like any other evaluation, *may* be delayed until (but not
later than) the sequence point. The evaluation order between consecutive
sequence points is up to the implementor.

and the standard has an elaborate explanation of where sequence
points occur.

Indeed.

They make C programs easier to optimize and pipeline since you don't
want to wait, in p++ for the postincrement to occur (which is a memory
access) after stacking p.

That's up to the implementor. Anyway, well done - you've finally worked out
why x=x-- is undefined in C (and C++).

You could be a hardass on the order of a
Wirth and insist that p++, as a legacy mistake,

Begging the question. It has not been demonstrated that post-increment is a
mistake, legacy or otherwise.

be implemented as an
indivisible atomic operation in the interest, under-represented on the
committee, of safety and therefore humanity but it appears that the
Standards committee members were birds of a Feather.

Translation: you screwed up because you didn't understand how evaluation
order works in C, and now you're claiming that it's a safety issue because
there might be other people using C who are as bad at it as you are. Well,
maybe that's possible - stranger things have happened - but C was designed
for use by skilled programmers. Sharp tools have sharp edges, by
definition. Don't run with scissors.


The problem is that this nonsense invalidates existing C code

Not properly written code, no. But yes, it may well invalidate some of your
code.

<the usual sociology snip>

I could see the wisdom of the standards team: all I have to do is not
use C, and I am delighted not to use C.

Right - all you have to do is leave C alone and let C programmers get on
with using it.

<more sociology snipped>

Insofar as this code was coded by programmers who expected p++ to be
atomic (in a statement which doesn't assign it),

....it should be fixed by programmers who Actually Know The Language. What a
radical idea!

<snip>

I don't think Herb Schildt understood what was going on in the
standard.

Unwittingly, you have spoken the truth at last: Herbert Schildt did indeed
fail to understand the Standard.

But if he had, and had explained it properly, there might

....have been much less reason to criticise his C writings.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: Sequence points
    ... that's a technical corrigendum and not the standard itself. ... in p++ for the postincrement to occur (which is a memory ... If his books are read by as many people as you claim and he had gained and shown that understanding, then there might have been a revolution: more well-taught C programmers. ...
    (comp.programming)
  • Re: string upper, string lower, string subthisforthat
    ... | This requirement appears in the public draft standard (which is what ... as 'transform' can be used to modify a sequence in place ... | (i.e. one of the input iterators can be the same as the output ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Goodsteins Theorem
    ... all ordinals below epsilon_0. ... given Goodstein sequence is bounded in Peano Arithmetic, ... interpretation of Goodstein's Theorem as a number-theoretic assertion ... as standard PA, ought not to be accepted as definitive. ...
    (sci.logic)
  • Re: Goodsteins Theorem
    ... PA^- plus Sigma_1 induction) to arithmetical transfinite induction on ... all ordinals below epsilon_0. ... given Goodstein sequence is bounded in Peano Arithmetic, ... as standard PA, ought not to be accepted as definitive. ...
    (sci.logic)
  • Re: x=(x=5,11)
    ... But the standard is not ambiguous at all. ... There is a sequence point ... This was a red herring when it first entered the conversation and is ... sequence points is to insure that the evaluation is complete. ...
    (comp.lang.c)