🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9500

Sequence of evaluation

#9500
From: Joshua W. Knight
Date: Mon, 06 Oct 1986 16:58
25 lines
1950 bytes
I've run the a = ((b=1),b) + ((b=2),b) + ((b=3),b) ; program on several
compilers (AT&T 370 C compiler, Masscomp C compiler, IBM ACIS 4.2
compiler for the IBM RT/PC, and the PC/IX compiler) and they all get 9.
I'm also essentially positive that all these compilers are PCC based.
I recently had a chance to read the minutes from the June 1986 ANSI C
standardization meeting.  It seems to me that they have made it
mandatory for the result to be 6 (the relevant point is that the comma
operator provides a "sequence point").  The only draft of the full ANSI
standard that I have is well over a year old and it seems to me to leave
the order of evaluation as "implementation dependent".  The change from
the April 1985 draft to the current version (under the assumption that
I've got it straight) would seem to make many current compilers (most
PCC based compilers) out of compliance with the standard.  This isn't
necessarily a bad thing per se (code that depends on this behavior of
PCC derived compilers is clearly non portable), but I'm not sure that
having the order of evaluation specified for comma operators is worth
the trouble it might cause optimizing compilers.  Besides, if (as it
seems) PCC derived compilers do "for effect" evaluations first, there
might be more reasonable code that is "broken" by this change.

Of course, I speak only for myself, not my employer.

			Josh Knight
			IBM T.J. Watson Research Center
josh@ibm.com, josh@yktvmh.BITNET
Technical Details
Message-ID: <4379@brl-smoke.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!caip!brl-adm!brl-smoke!smoke!JOSH@ibm-sj.ARPA

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!caip!brl-adm!brl-smoke!smoke!JOSH@ibm-sj.ARPA
From: JOSH@ibm-sj.ARPA (Joshua W. Knight)
Newsgroups: net.lang.c
Subject: Sequence of evaluation
Message-ID: <4379@brl-smoke.ARPA>
Date: Mon, 6-Oct-86 12:58:08 EDT
Article-I.D.: brl-smok.4379
Posted: Mon Oct  6 12:58:08 1986
Date-Received: Tue, 7-Oct-86 23:51:59 EDT
Sender: news@brl-smoke.ARPA
Lines: 25