Article View: net.lang.c
Article #9405Re: Evaluation of function arguments (w
From: wsmith
Date: Fri, 26 Sep 1986 19:53
Date: Fri, 26 Sep 1986 19:53
53 lines
1531 bytes
1531 bytes
>int i;
> i = 0;
>f ( i++, i++, i++);
>write(i);
> f( a,b,c) int a,b,c;
> write (a,b,c);
>
Because the expression being used in your program is un-defined in
the C language, lint complains about such non-sensical programs,
saying evaluation order undefined.
Your program could be translated into something like this:
load r0,i
pusharg r0
load r1,i
pusharg r1
load r2,i
pusharg r2
inc r2
load i,r2
inc r1
load i,r1
inc r0
load i,r0
call f
....
In which case, the program would print out:
0 0 0
1
Another possibility that will probably generate fewer flames is:
0 0 0
3
I don't know of a compiler that does such nonsense, but I think one could.
A safer program is
main()
{
int i;
f(g(&i),g(&i),g(&i));
write(i);
}
f(a,b,c) int a,b,c;
{ write (a,b,c); }
g(pi) int * pi;
{ return( (*pi)++ ); }
Bill Smith
ihnp4!uiucdcs!wsmith
wsmith@a.cs.uiuc.edu
Technical Details
Message-ID:
<139200035@uiucdcsb>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!wsmithReferences:
<3966@brl-smoke.ARPA>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!cbatt!ihnp4!inuxc!pur-ee!uiucdcs!uiucdcsb!wsmith From: wsmith@uiucdcsb.cs.uiuc.edu Newsgroups: net.lang.c Subject: Re: Evaluation of function arguments (w Message-ID: <139200035@uiucdcsb> Date: Fri, 26-Sep-86 15:53:00 EDT Article-I.D.: uiucdcsb.139200035 Posted: Fri Sep 26 15:53:00 1986 Date-Received: Tue, 30-Sep-86 05:02:37 EDT References: <3966@brl-smoke.ARPA> Lines: 53 Nf-ID: #R:brl-smoke.ARPA:3966:uiucdcsb:139200035:000:888 Nf-From: uiucdcsb.cs.uiuc.edu!wsmith Sep 26 14:53:00 1986