🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2165

Re: order of sequence points in subexpressions

#2165
From: Norman Diamond
Date: Wed, 30 Sep 1992 08:29
37 lines
2194 bytes
In article <1992Sep29.222521.9221@kai.com> david@kai.com (David Nelson) writes:
>[...] what about: "a = b[i+=1,i] + c[i+=1,i];".

The commas introduce sequence points, but they might occur in either order,
or they might even occur simultaneously.  For example, a hypothetical
implementation could order the operations as:
  [previous sequence point]
  i+=1
  i+=1
  , sequence point
  , sequence point
  fetch i
  compute address of c[i] and fetch it
  remember fetched i (or fetch again if volatile; might occur earlier)
  compute address of b[i] and fetch it
  add
  assign to a
  ; sequence point
The two modifications to the stored value between the previous sequence
point and the first sequence point visible here violate this "shall":
>From ANSI 3.3 Expressions
>     Between the previous and next sequence point an object shall have its
> stored value modified at most once by the evaluation of an expression. 

... and your program might post an "F*** you all" message to alt.pictures.

>My interpretation would be that the sequence point only affects the
>subexpression of the operation that introduced the sequence point.

I think you mean the subexpression[s] that are operand[s] of the operation
that introduced the sequence point -- for example, comma takes two operands.
That would have been a very nice definition (in my personal opinion).
The standard didn't do it that way though.
--
Norman Diamond       diamond@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"Yeah -- bad wiring.  That was probably it.  Very bad."
Technical Details
Message-ID: <1992Sep30.082946.9064@nntpd.lkg.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!deccrl!news.crl.dec.com!news!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
References: <1992Sep29.222521.9221@kai.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!deccrl!news.crl.dec.com!news!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
From: diamond@jit345.bad.jit.dec.com (Norman Diamond)
Subject: Re: order of sequence points in subexpressions
Message-ID: <1992Sep30.082946.9064@nntpd.lkg.dec.com>
Keywords: sequence points
Sender: usenet@nntpd.lkg.dec.com (USENET News System)
Reply-To: diamond@jit.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
References: <1992Sep29.222521.9221@kai.com>
Date: Wed, 30 Sep 1992 08:29:46 GMT
Lines: 37