Re: com php-src: fix negating an unsigned: Zend/zend_operators.h
| From: | Nikita Popov | Date: | Mon, 15 Sep 2014 20:02:45 +0000 |
| Subject: | Re: com php-src: fix negating an unsigned: Zend/zend_operators.h | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-81664@lists.php.net to get a copy of this message | ||
On Mon, Sep 15, 2014 at 7:46 PM, Anatol Belski <ab@php.net> wrote:
> Commit: e0ff5238c5d744509f93aaf914e23f17d51c5ae3
> Author: Anatol Belski <ab@php.net> Mon, 15 Sep 2014 17:48:15
> +0200
> Parents: 383a0773ff27cf57b94fe11d2f825b00cff88714
> Branches: master
>
> Link:
>
> http://git.php.net/?p=php-src.git;a=commitdiff;h=e0ff5238c5d744509f93aaf914e23f17d51c5ae3
>
> Log:
> fix negating an unsigned
>
> Changed paths:
> M Zend/zend_operators.h
>
>
> Diff:
> diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
> index 41342de..a50e65d 100644
> --- a/Zend/zend_operators.h
> +++ b/Zend/zend_operators.h
> @@ -1036,7 +1036,7 @@ static zend_always_inline void
> fast_is_not_identical_function(zval *result, zval
> /* buf points to the END of the buffer */
> #define _zend_print_signed_to_buf(buf, num, vartype, result) do {
> \
> if (num < 0) {
> \
> - _zend_print_unsigned_to_buf((buf), -(vartype)(num), vartype,
> (result)); \
> + _zend_print_unsigned_to_buf((buf), (~((vartype)(num)) + 1),
> vartype, (result)); \
> *--(result) = '-';
> \
> } else {
> \
> _zend_print_unsigned_to_buf((buf), (num), vartype, (result));
> \
>
Why this change? Unary minus of an unsigned value is a well-defined
operation, see C89 3.1.2.5c5 or C99 6.2.5c9. Writing it this way seems much
less clear to me. Unary minus is the operation that we mean here
semantically.
Nikita