Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!brutus.cs.uiuc.edu!ginosko!uunet!algor2.algorists.com!jeffrey From: jeffrey@algor2.algorists.com (Jeffrey Kegler) Newsgroups: comp.std.c Subject: Re: No sequence points in assignment Message-ID: <1989Sep13.005247.20121@algor2.algorists.com> Date: 13 Sep 89 00:52:47 GMT References: <1021@m3.mfci.UUCP> Reply-To: jeffrey@algor2.UUCP (Jeffrey Kegler) Distribution: comp Organization: Algorists, Inc. Lines: 22 In article <1021@m3.mfci.UUCP> karzes@mfci.UUCP (Tom Karzes) writes: >Consider the following statement: > > x = a + (x = b); > >Could the assignment for (x = b) be performed after the outer >assignment? In ANSI C (3.3), this is undefined behavior, meaning anything (core dump, generation of random number, etc.) can happen. In all likelihood, and in Classic C, you get the assignments performed in whatever order amuses the compiler. In any case, the practical implications are the same. Anyone coming across statements like this in code should rearrange them to introduce a sequence point. Breaking the above into two statements, or rearrangement around a comma operator, will do it in the above. -- Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc. jeffrey@algor2.ALGORISTS.COM or uunet!algor2!jeffrey 1762 Wainwright DR, Reston VA 22090