Re: Bug #11685 Updated: Bad Auto-Cast
| From: | Jeroen van Wolffelaar | Date: | Tue, 26 Jun 2001 11:53:00 +0000 |
| Subject: | Re: Bug #11685 Updated: Bad Auto-Cast | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-58033@lists.php.net to get a copy of this message | ||
> Old-Status: Open
> Status: Bogus
> <?php
> $var=-1073741824;
> #####^ Here!
>
> $var*=2;$var*=2;
> var_dump($var);
> ?>
> It will print out "int(0)".
> but I believe it should print out"int(-2147483648)" or
"float(-2147483648)" like this program:
IMO the output is wrong indeed. On integer overflow, it should be
automatically converted to float.
In zend_operators.c, line 614. there is only a check for integer addition
overflow towards POSITIVE infinity, NOT the other way around.
Same story with substraction and multiplication (the latter one being the
issue here.)
I'll submit a patch later today.
Jeroen