Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c
| From: | Zeev Suraski | Date: | Thu, 01 Jun 2000 14:48:07 +0000 |
| Subject: | Re: [PHP4BETA] cvs: php4 /ext/standard/ string.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-16038@lists.php.net to get a copy of this message | ||
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 <zeev@zend.com>
http://www.zend.com/