From: Brian Hawley <bhawley@lu...> - 2004-09-15 23:26:08
At 07:08 PM 9/13/2004 -0700, Dave Hylands wrote:
> > But, in the posters example,
> > c == c++
> > the operands to == are c and c++, and both must evaluate before the
> > comparison. c evaluates to the value c. c++
> > evaluates to the value c+1. Here, the order is irrelevant
> > both operands
> > will evaluate before the == operator is applied.
>Yes it is true that both operands will be evaluated before the ==
>operator is applied.
>However you stated that c++ evaluates to c+1. This is incorrect. The
> c = 7;
> x = c++;
>Will assign the value 7 to x, not 8.
I agree...however, the assignment operator is not the same as a relOP.
>But that's just an aside; what's important here, is does the ++ occur
>before or after the left hand side of the == is evaluated? The compiler
>is free to choose either one.
>Similarly, if you compile
> if ( f() == g() )
>You can't predict if f or g will be called first, just that they'll both
Absolutely...but you know that both will execute before the ==. I still
that the left side of c == c++ will evaluate to c, while the right side
right side will evaluate to c+1. For exactly the same reason as
c * 4 + 3
var mulOP var plusOP var
you can guarantee the order the var's will evaluate in, but you can
the mulOP will apply to the first two var's and that both of those vars
before the mulOP will apply, and so on.
using f() or f isn't just a var, it is a var plus another operator. So,
are not the same as the simple example in the original post.
However, we are still debating a point which the original poster didn't
ask. Can anyone
see why his second test does not evaluate to 1?
>Vancouver, BC, Canada
>This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
>Project Admins to receive an Apple iPod Mini FREE for your judgement on
>who ports your project to Linux PPC the best. Sponsored by IBM.
>Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
>MinGW-users mailing list
>You may change your MinGW Account Options or unsubscribe at:
Brian N. Hawley bhawley@...
Luminex Software, Inc. http://www.luminex.com
PO Box 5908 voice: 909-781-4100 x112
Riverside, CA 92517 fax: 909-781-4105