From:             d_kelsey at uk dot ibm dot com
Operating system: Linux 64Bit
PHP version:      5.2CVS-2009-02-17 (CVS)
PHP Bug Type:     Scripting Engine problem
Bug description:  not operator does a c cast to long which is different to 
other ops

Description:
------------
In zend_operators.c the function ZEND_API int bitwise_not_function(..)
handles a double by doing a c cast to a long
"if (op1->type == IS_DOUBLE) {
        op1->value.lval = (long) op1->value.dval;
        op1->type = IS_LONG;
}"

but all other operators use the zendi_convert_to_long() macro
so not isn't consistent with the other operators.

this can result in an unexpected value as shown in the test case

Reproduce code:
---------------
<?php
define("MAX_64Bit", 9223372036854775807);
$e = (MAX_64Bit + 1);
$f = (int)$e;
var_dump(~(MAX_64Bit + 1));
var_dump(~$f);
?>


Expected result:
----------------
int(-9223372036854775808)
int(-9223372036854775808)

Actual result:
--------------
int(9223372036854775807)
int(-9223372036854775808)


-- 
Edit bug report at http://bugs.php.net/?id=47424&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47424&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47424&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47424&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47424&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47424&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47424&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47424&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47424&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47424&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47424&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47424&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47424&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47424&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47424&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47424&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47424&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47424&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47424&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47424&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47424&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47424&r=mysqlcfg

Reply via email to