Path: utzoo!attcan!uunet!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.lang.c Subject: Re: Is something wrong with the compiler ? Message-ID: <1895@tuvie> Date: 2 Oct 90 14:58:52 GMT References: <884@gtenmc.UUCP> <1990Sep26.175948.8232@zoo.toronto.edu> <189@thor.UUCP> Sender: news@tuvie Lines: 30 scjones@thor.UUCP (Larry Jones) writes: >In article , burley@world.std.com (James C Burley) writes: >> > a = ( int )(( unsigned ) ( a = ~0 ) >> 1 )); >> >No, '=' is not a sequence point. The question in this case is not when >the lhs gets evaluated, but when the actual storage of the rhs into the >lhs is done. A compiler would be completely within its rights to store >the final result into a and then overwrite it with ~0. Yes, but the variable 'a' was not used afterwards, so we are not interested in the value of a, but in the value of the complete expression, which is IMHO well defined (The standard says in 3.3.16: An assignment expression has the value of the left operand after the assignment). Expression: Value: (a = ~0) (int) ~0 (unsigned)(a = ~0) (unsigned) ~0 ((unsigned)(a = ~0) >> 1) (unsigned) MAXINT (int)((unsigned)(a = ~0) >> 1) (int) MAXINT a = (int)((unsigned)(a = ~0) >> 1) (int) MAXINT Anything wrong with my reasoning? -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technische Universitaet Wien | as evolution | | | | | hp@vmars.tuwien.ac.at | in action! | | __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |