Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c

[email protected] (Zeev Suraski) Thu, 1 Jun 2000 17:48:07 +0300 (IDT)
Newsgroups php.version4
Message-ID <[email protected]>
On Thu, 1 Jun 2000, Hartmut Holzgraefe wrote:

> Andrei Zmievski wrote:
>  
> > > -                     *++r=toupper((unsigned char)*r);
> > > +                     *r=toupper((unsigned char)*++r);
> > 
> > Are you sure about this? It seems that you're replacing space 
> > character with the uppercased next one.
> 
> the two assignments are equivalent, as the ++ operator has
> a higher precedence then assingments or pointer de-referencing

It's true that both of these assignments are equivalent - they're equally
buggy.

It has nothing to do with precedence.  The assignment operator can't be
executed until both the lvalue and rvalue are calculated;  There's NO
provision for either of these values to be calculated before the other.
In this case, a proof using an example isn't good enough - it won't crash,
and it may consistently behave in one of the two ways it may - but it's
pure luck.

Zeev

-- 
Zeev Suraski <[email protected]>
http://www.zend.com/