Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!algor2.algorists.com!jeffrey From: jeffrey@algor2.algorists.com (Jeffrey Kegler) Newsgroups: comp.std.c Subject: Re: Denotational Semantics and Language Standards Message-ID: <1989Nov11.072634.12936@algor2.algorists.com> Date: 11 Nov 89 07:26:34 GMT References: <11065@riks.csl.sony.co.jp> <2727@cbnewsl.ATT.COM> <11477@smoke.BRL.MIL> <11081@riks.csl.sony.co.jp> <11555@smoke.BRL.MIL> <1989Nov8.222632.699@algor2.algorists.com> <1989Nov8.225008.793@algor2.algorists.com> <11571@smoke.BRL.MIL> <813@ccssrv.UUCP> Reply-To: jeffrey@algor2.ALGORISTS.COM (Jeffrey Kegler) Organization: Algorists, Inc. Lines: 29 PH> Article <813@ccssrv.UUCP> perry@ccssrv.UUCP (Perry Hutchison) JK> Article <1989Nov9.151708.3617@algor2.algorists.com> jeffrey@algor2.algorists.com (Jeffrey Kegler) JK> the result of JK> JK> int f(int a, int b) { return a+b; } JK> ... JK> i = 2; i = f(i = 3, i); JK> JK> is indeterminate. Variable i can be either 5 or 6, after this PH> It can also be 3. In fact, it is probably legal for i to have any value PH> whatsoever, or for the program to dump core. I checked this before posting. Evaluation order of arguments is covered by 3.3.2.2 which treats this as unspecified behavior, not undefined behavior. (See also A.6.1). So no core dumps are allowed in conforming implementations. As for 3 being a possible result, the function call is a sequence point (A.2 and 3.3.2.2), as is the expression in the return statement (3.6). So the addition must be performed prior to the assignment (2.1.2.3). -- Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc. jeffrey@algor2.ALGORISTS.COM or uunet!algor2!jeffrey 1762 Wainwright DR, Reston VA 22090