Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!deimos!uxc!tank!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: side effects in argument lists
Message-ID: <14758@mimsy.UUCP>
Date: 30 Nov 88 11:48:37 GMT
References: <1077@mina.liu.se>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 28

In article <1077@mina.liu.se> mikpe@mina.liu.se (Mikael Pettersson) writes:
>Consider the following program:

[edited]
>void bletch(int junk) { printf("count == %d\n", count); /* 0 or 1 ? */ }
>main() { bletch(count++);

>This program exemplifies the situation where the behaviour of the
>callee depends on whether the caller has completed *all* of the
>side effects from evaluating the arguments of the call or not.

>Q: what sayeth the dpANS about this?

The dpANS sayeth that the program is to print `1'.  All side effects
are to have completed by the next `sequence point'.  The list of
sequence points includes comma expressions, `&&', `||', and not
least, function calls.  Obviously, statement bounardies (semicolons)
are sequence points as well.

>If count++ _is_defined_as_ (++count, count-1) then I guess things
>are cool, but what if the definition is less strict?

The definition is less strict, but the side effect is done by the
next sequence point.  Insert a sequence point and your side effect
is guaranteed; without it, it is not.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris