Re: Zend engine bug

From: Date: Wed, 05 Sep 2001 17:29:51 +0000
Subject: Re: Zend engine bug
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-65167@lists.php.net to get a copy of this message
On Wed, 5 Sep 2001, Zeev Suraski wrote: > >If the type of either operand is greater than long, it cannot be demoted > >(from double) without overflowing lval and giving unexpected results. > > But when you overflow an integer, you get unexpected results. The only > thing this code does is that in certain cases, where the lval would have > been overflown and populated with meaningless info, instead, it populates > it as if it's an unsigned long. If you use this information bitwise, then > it's useful. This is where the problem is coming in, and this is what would be solved. Numbers over LONG_MAX are treated as doubles and cast to unsigned long. It doesn't solve the problem. That would involved one of two things: people can only perform bitwise/mod on long ints or zval supports precision arithmetic values. The latter would be a fair bit of work and cost plenty of memory unless the BCMath precision support was extended to bitwise (it currently solves the mod problem). > > >Instead, the relevant operations could be performed on unsigned longs, > >with the result being cast to the most appropriate type (double or > >long) based on whether op1 & op2 <= LONG_MAX. > > Can you give an example of something that doesn't work with the way the > code is currently? echo (2147483649 & 2147483649); echo (2147483649 % 5); etc. > > Zeev > Gavin

« previous php.dev (#65167) next »