Article View: comp.std.c
Article #2634Re: Function Argument Evaluation
From: Ed Gould
Date: Thu, 28 Mar 1991 19:46
Date: Thu, 28 Mar 1991 19:46
28 lines
1165 bytes
1165 bytes
>I would be very interested in seeing a program whose behavior
>was *not* undefined, yet could arbitrarily produce either of two
>drastically different outputs depending solely on the unspecified
>order of evaluation.
Will this do?
foo() {
int v = 1;
printf("%d %d\n", v, ++v);
}
It may print either
1 2
or
2 2
depending solely on order of evaluation. Are there any other
things here that make this program's behavior undefined? I
think not.
--
Ed Gould mt Xinu, 2560 Ninth St., Berkeley, CA 94710 USA
ed@mtxinu.COM +1 415 644 0146
"I'll fight them as a woman, not a lady. I'll fight them as an engineer."
Technical Details
Message-ID:
<1991Mar28.194627.26285@mtxinu.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mtxinu!edReferences:
<3461@inews.intel.com> <1991Mar26.181821.22912@cs.ucla.edu> <17936@crdgw1.crd.ge.com> <15607@smoke.brl.mil> <17983@crdgw1.crd.ge.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mtxinu!ed From: ed@mtxinu.COM (Ed Gould) Newsgroups: comp.std.c Subject: Re: Function Argument Evaluation Message-ID: <1991Mar28.194627.26285@mtxinu.COM> Date: 28 Mar 91 19:46:27 GMT References: <3461@inews.intel.com> <1991Mar26.181821.22912@cs.ucla.edu> <17936@crdgw1.crd.ge.com> <15607@smoke.brl.mil> <17983@crdgw1.crd.ge.com> Reply-To: ed@mtxinu.COM (Ed Gould) Organization: mt Xinu, Berkeley Lines: 28