🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9415

Re: Expression sequencing query

#9415
From: Gary McKenney
Date: Fri, 26 Sep 1986 12:54
25 lines
1742 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?
> >
> Tom, I agree, the result should be 6, as defined by K&R, but I have tried
> it on a Cyber 180/830 running NOS VE, and get 9, also AT&T's 3B5
> System V, gets 9, But A copy of the Small-C Compiler that I have ported
> comes up with a 6.  Does this seam to imply that Small-C is a better
> (more accurate) compiler, than those that AT&T produces?  I find it
> totally unaccepable that AT&T can not produce a working C compiler.
> I would like everyone to test it on as many machines as prossible, to
> see if we can find as least ONE other besides Small-C, that works.
> 
> Mike Stump  ucbvax!hplabs!csun!csunb!beusemrs

You are both wrong.  All expressions in lowest set of parenthesis are evaluated
first from left to right, therefore before any addition occurs b = 3.
a = 3 + 3 + 3;

gbm
Technical Details
Message-ID: <673@galbp.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!codas!akguc!akgua!akgub!galbp!gbm
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!watmath!clyde!burl!codas!akguc!akgua!akgub!galbp!gbm
From: gbm@galbp.UUCP (Gary McKenney)
Newsgroups: net.lang.c
Subject: Re: Expression sequencing query
Message-ID: <673@galbp.UUCP>
Date: Fri, 26-Sep-86 08:54:48 EDT
Article-I.D.: galbp.673
Posted: Fri Sep 26 08:54:48 1986
Date-Received: Tue, 30-Sep-86 07:38:26 EDT
References: <760@oakhill.UUCP> <111@titan.UUCP>
Distribution: net
Organization: Lanier Business Products, Inc., Atlanta, Georgia
Lines: 25