use of if (!cptr) and if (cptr) && a programming error
Doug Gwyn
gwyn at smoke.BRL.MIL
Sat Jul 22 17:51:48 AEST 1989
In article <2990 at nmtsun.nmt.edu> dwho at nmtsun.nmt.edu (David Olix) writes:
-> while ( ( myptr = my_func() )->x != myptr->y )
->THAT WILL NOT WORK! [...]
-Actually, "Mastering C" by Craig Bolon, SYBEX Inc., p. 273 says that
-parenthesis operators have the HIGHEST priority, therefore what's inside
-(myptr = my_func()) would get evaluated first. Also, it specifies that
-grouping for the '!=' operator is from left to right.
That's confusing precedence and associativity, which determine how to
parse the expression, with order of execution. Execution order is
mainly constrained by what are called "sequence points" in the pANS.
There are some sequence points within the expression, but not enough
to disambiguate the use of `myptr'.
More information about the Comp.lang.c
mailing list