🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #600

Re: No sequence points in assignment

#600
From: Ronald Guilmette
Date: Mon, 18 Sep 1989 03:57
48 lines
2837 bytes
In article <5059@merlin.usc.edu> jeenglis@nunki.usc.edu (Joe English) writes:
>karzes@mfci.UUCP (Tom Karzes) writes:
>>I have a question about assignment expressions.  According to the standard,
>>an assignment expression does not introduce a sequence point, although the
>>side effect of updating the stored value of the left operand must occur
>>between the previous sequence point and the next sequence point.  This
>>seems to imply that in an expression with multiple assignments, the actual
>>assignments may occur in any order provided the stored values can be
>>determined and the assignments all take place between the previous
>>sequence point and the next sequence point.  If this interpretation is
>>correct, it seems to me that it can lead to some counter intuitive
>>results.  For example, consider the following statement:
>>
>>    x = a + (x = b);
>>
>>Could the assignment for (x = b) be performed after the outer
>>assignment?

>
>As far as I know, yes.  I have a question, though:  Does it really
>matter?  There seems to be a lot of traffic lately asking questions
>like:  "Will (obviously buggy and weird code) work like you would
>expect it to, or is the compiler allowed to do something other than
>What I Mean?" 
>
>I fail to see how these questions are relevant...

If you don't understand why such questions *are* relevent to this newsgroup
then maybe you are reading the wrong newsgroup.  You obviously don't
understand what the standardization effort is all about.

Consider this.  You are given a piece of code and asked to port it to your
company's new ZLOP-19 micro-supercomputer.  The guy who wrote the code (let's
call him Fred) left the company six months ago.  You recompile the code on
the ZLOP-19 and run it.  It issues a prompt and core dumps.  You spend an
hour with your favorite debugger and track the problem to the following
statement:

	x = a + (x = b);

Now you know this program worked fine on the good ol' VAX, so what is the
problem?  Should you (a) tell your boss that Fred was a turkey who wrote
non-ANSI (and non-portable) code and then change the code or (b) contact your
compiler vendor to file a bug report.

Only the "standard" can help you decide on the proper action.

// rfg
Technical Details
Message-ID: <1989Sep18.035704.20113@paris.ics.uci.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!ucsd!orion.cf.uci.edu!uci-ics!rfg
References: <1021@m3.mfci.UUCP> <5059@merlin.usc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!ucsd!orion.cf.uci.edu!uci-ics!rfg
From: rfg@ics.uci.edu (Ronald Guilmette)
Newsgroups: comp.std.c
Subject: Re: No sequence points in assignment
Message-ID: <1989Sep18.035704.20113@paris.ics.uci.edu>
Date: 18 Sep 89 03:57:04 GMT
References: <1021@m3.mfci.UUCP> <5059@merlin.usc.edu>
Sender: news@paris.ics.uci.edu (Network News)
Reply-To: Ronald Guilmette <rfg@ics.uci.edu>
Distribution: comp
Organization: University of California, Irvine - Dept of ICS
Lines: 48