*BSD News Article 82474


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!news.kei.com!news.mathworks.com!www.nntp.primenet.com!nntp.primenet.com!news1.best.com!nntp1.best.com!usenet
From: dillon@flea.best.net (Matt Dillon)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: gcc standards question (was blank)
Date: 7 Nov 1996 23:43:56 GMT
Organization: BEST Internet Communications, Inc.
Lines: 37
Message-ID: <55ts7s$dd6@nntp1.best.com>
References: <55tme9$n27@james.freenet.hamilton.on.ca>
NNTP-Posting-Host: flea.best.net

:In article <55tme9$n27@james.freenet.hamilton.on.ca>,
:Tim Vanderhoek <ac199@james.freenet.hamilton.on.ca> wrote:
:> wrote:
:>> 
:>> This program doesn't work as I think it should.   On line 10, b is not 
:>> incremented between the first and second b++'s, though it is correct
:>> after the entire expression.
:>
:>I won't swear to it, but I believe the results to that particular line are
:>"undefined" in most standards (and with good reason -- ie. what should a
:>line like a=b++*2||a[b]; produce?  It could conceviably be optimized
:>either waw). 
:>
:>
:>>         a=c[b++]|((c[b++])<<8);
:>
:>
:>-- 
:>tIM...HOEk
:>"Perception is often reality - or at least it is perceived as to be so"
:>              - Scott Nudds [in usenet or email]

    Yes, this is definitely an undefined operation, just as something like:

    fubar(b, b++)

    is an undefined operation.  There is NOTHING that says that the 
    post-incrementation of b must occur after all the procedure arguments
    have been evaluated.  Same goes for:

	a = b++ + b;

    The ONLY ordering you can count on in C is the statement-to-statement
    ordering, && and || ordering, and comma operator ordering.

				-Matt