🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4430

Re: On sequence points and evaluation order

#4430
From: Nick Maclaren
Date: Mon, 04 Dec 1995 18:57
34 lines
1969 bytes
In article <49qtc0$72g@light.twinsun.com>,
Paul Eggert <eggert@twinsun.com> wrote:
>This point has been debated before.  Some people think the standard
>says `f()+f()' has undefined behavior when f has side effects
>(e.g. if f is defined by `int f() { static int i; return i++; }').
>Other people think the standard defines behavior for `f()+f()'.
>Still other people think that that this example has undefined behavior,
>but other, similar examples have defined behavior.

The example that really baffles me is '(++i,j)+(j,++i)', because the
standard assumes an ordering of operations without defining what that
ordering is.  If anyone thinks that this example is easy, write out
the parse tree and consider its consequences!

>I don't know if the ISO C committee has issued an official ruling on this.
>It is clearly an unnecessarily messy area in the C Standard.

This is a little unfair, in that X3J11 had a horrible task trying to
specify anything workable.  Admittedly, they might have done better
than they did, but whatever is specified is bound to be either messy
or a severe restriction on existing practice.

>As a practical matter, if the implementation does function inlining,
>I wouldn't rely on the behavior being well-defined here.

Absolutely!  Nor would I rely on it if the compiler supports any
automatic parallelisation.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679
Technical Details
Message-ID: <49vgb5$muj@lyra.csx.cam.ac.uk>
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
References: <49l428$od0@bolverk.cs.cornell.edu> <49qtc0$72g@light.twinsun.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: On sequence points and evaluation order
Date: 4 Dec 1995 18:57:41 GMT
Organization: University of Cambridge, England
Message-ID: <49vgb5$muj@lyra.csx.cam.ac.uk>
References: <49l428$od0@bolverk.cs.cornell.edu> <49qtc0$72g@light.twinsun.com>
NNTP-Posting-Host: bootes.cus.cam.ac.uk