On Wed, Nov 06, 2002 at 05:46:53PM +0100, Marc Olzheim wrote:
> ..
> if ((nd = parse_char_class(++nd)) == NULL) {
> ..
> 
> Hmmm... is this legal ?
> 
> http://www.eskimo.com/~scs/C-faq/q3.1.html seems to tell otherwise...

In this particular case, the value of 'nd' is not *used* anywhere in the
expression.  The fact that 'nd' is *assigned to* is not influenced in
any way by the change of its value.

It is absolutely certain that the compiler will put the code calculating
the value of the argument to parse_char_class() before the code actually
invoking parse_char_class(), and that it will also place the code
invoking parse_char_class() before the code which assigns the return
value to 'nd'.. thus, it is absolutely certain that 'nd' will be
assigned the correct value.

Once again: the main reason why q3.1 is not relevant here is the fact
that q3.1 deals with expressions where the value of 'nd' is used; here,
the left side of the assignment does not 'use' the value, it *changes*
it :)

Hope that helps.

G'luck,
Peter

-- 
Peter Pentchev  [EMAIL PROTECTED]        [EMAIL PROTECTED]
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I've heard that this sentence is a rumor.

Attachment: msg37844/pgp00000.pgp
Description: PGP signature

Reply via email to