Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.std.c Subject: Re: No sequence points in assignment Message-ID: <1033@m3.mfci.UUCP> Date: 19 Sep 89 04:43:29 GMT References: <1021@m3.mfci.UUCP> <1989Sep13.005247.20121@algor2.algorists.com> <1026@m3.mfci.UUCP> <10851@riks.csl.sony.co.jp> Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Distribution: comp Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 28 In article <10851@riks.csl.sony.co.jp> diamond@riks. (Norman Diamond) writes: -In article <1026@m3.mfci.UUCP> karzes@mfci.UUCP (Tom Karzes) quotes: - ->The second paragraph in section 3.3 says: -> Between the previous and next sequence point an object shall have -> its stored value modified at most once by the evaluation of an -> expression. Furthermore, the prior value shall be accessed only -> to determine the value to be stored. - -Even if the expression contains two assignments to the same object? -(As did the example which led to this thread.) Even without the -optimizer turned on, the compiler is REQUIRED to notice and delete -all but one assignment to the same object? - -(Uh, remember that other thread about whether two pointers are equal, -and it depends on whether they point to the same object, i.e. things -like ring numbers have to be masked out.) Wow, a non-optimizing -compiler is going to have to do a lot of alias checking in order to -meet section 3.3. This paragraph is merely describing restrictions on the side effects a user may have in an expression. An ANSI conforming C compiler certainly isn't required to detect every situation in which this is violated. It would be nice if it could detect some of the cases at compile time, but at best it would only be able to catch a few simple instances (most likely involving direct scalar references). The point is that a compiler writer doesn't have to worry about the behavior of cases like this because they are explicitly disallowed by the standard.