🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9468

a=(b=1,b)+(b=2,b)+(b=3,b); /*ANSI does NOT say a=6*/

#9468
From: Wayne Throop
Date: Thu, 02 Oct 1986 15:20
29 lines
1909 bytes
Some folks have said that since (,) expressions are sequence points,
the result of the expression in the Subject: line must be 6.
I don't think so.  I could be wrong, but it seems pretty straightforward
to me.  Take this example:

        (e1,e2)+(e3,e4)

Now, the way I read ANSI, the sequence points at the (,) expressions
prohibit the interleaving of the evaluation of e1 and e2, and similarly
prohibits the interleaving of e3 and e4.  But it does *NOT* (as far as
I can tell) prohibit the interleaving of e1 and e3, e1 and e4, e2 and e3,
or e2 and e4.  Thus, in the example that started the whole thing (the
expression in the Subject: line) the result could legitimately be anything
from 3 to 9, inclusive.

It is true that Harbison and Steele proposed a more restrictive set of
interleaving prohibitions.  These were *NOT* adopted by ANSI.  And,
perhaps more importantly, they were never implemented by most compilers.
Therefore, it is unwise to expect the H&S recommended behavior, since
most compilers do not adhere to it, and it is *INCORRECT* to say that
compilers that do not adhere to it are "buggy" or "broken", since both
K&R and the ANSI standard disagree with H&S on this point.

--
At one point I thought it would be easier to rewrite all my books
without using the letter 's'.
                                 --- D.E. Knuth
-- 
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw
Technical Details
Message-ID: <612@dg_rtp.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!bellcore!ulysses!allegra!mit-eddie!genrad!decvax!mcnc!rti-sel!dg_rtp!throopw

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!bellcore!ulysses!allegra!mit-eddie!genrad!decvax!mcnc!rti-sel!dg_rtp!throopw
From: throopw@dg_rtp.UUCP (Wayne Throop)
Newsgroups: net.lang.c
Subject: a=(b=1,b)+(b=2,b)+(b=3,b);  /*ANSI does NOT say a=6*/
Message-ID: <612@dg_rtp.UUCP>
Date: Thu, 2-Oct-86 11:20:39 EDT
Article-I.D.: dg_rtp.612
Posted: Thu Oct  2 11:20:39 1986
Date-Received: Sat, 4-Oct-86 10:50:28 EDT
Lines: 29