🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9385

Re: Re: Expression sequencing query

#9385
From: Dale Worley
Date: Wed, 24 Sep 1986 20:08
19 lines
1263 bytes
> In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
> >	/* a = b + b + b */
> >	a = ((b=1),b) + ((b=2),b) + ((b=3),b)
> >
> >I expected the result to be 6.  With the Microsoft C compiler and the
> >compiler on the Sun 3, the result is 9.  Apparently the parenthetical
> >assignments are all getting done before the comma and addition.  Any
> >thoughts on this?

Harbison&Steele (7.11) makes it clear that an implementation must
evaluate one argument of a binary operator completely before starting
evaluation of the other argument.  Thus, the result should be 6.  I
don't know what the ANSI standard says.

Dec VAX Ultrix gives 9.

Lattice C 3.00 for MS-DOS gives 7!!!  (Yes, that's "7", not a typo!)

Dale
Technical Details
Message-ID: <353@cullvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ll-xn!cullvax!drw
References: <760@oakhill.UUCP> <111@titan.UUCP>

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!ll-xn!cullvax!drw
From: drw@cullvax.UUCP (Dale Worley)
Newsgroups: net.lang.c
Subject: Re: Re: Expression sequencing query
Message-ID: <353@cullvax.UUCP>
Date: Wed, 24-Sep-86 16:08:32 EDT
Article-I.D.: cullvax.353
Posted: Wed Sep 24 16:08:32 1986
Date-Received: Wed, 24-Sep-86 22:21:56 EDT
References: <760@oakhill.UUCP> <111@titan.UUCP>
Distribution: net
Organization: Cullinet Software, Inc., Westwood, MA
Lines: 19