ID:               45068
 Updated by:       [EMAIL PROTECTED]
 Reported By:      philipm at sybase dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Variables related
 Operating System: Linux (32-bit only)
 PHP Version:      5.2.6
 New Comment:

This would seem to be caused by SIZEOF_LONG not being defined correctly
(e.g. 8 when it should be 4 on 32-bit)... I'm the one who made the
changes in 5.2.1 so most of the overhead to check for integer overflow
could be eliminated, etc. It didn't cause any tests to fail, and this is
the first issue I've heard. Also, I would expect numeric strings to fail
in the same way: '3000000000' + 0 ?

Is the result the same if you use an 11-digit number? Any more details
about your Linux system, in case there's something unique, might help
the Linux experts (not me) figure something else out. I'm not sure what
sets SIZEOF_LONG..... Oh wait, I was just looking at the configure
script, and noticed bits about "cross compiling" where SIZEOF_LONG is
defined -- do you know, is that something that applies in your
configuration?


Previous Comments:
------------------------------------------------------------------------

[2008-05-22 19:34:15] philipm at sybase dot com

Description:
------------
Entering a large integer immediate (i.e. bigger than INT_MAX) will
result in INT_MAX being used.  The issue is that these numbers cannot be
treated as integers in the zval, but for some reason the parser is
attempting to do so.  However, the various operators convert the large
number to a float, so they work okay.

For example, entering:

3000000000 gives 2147483647
3000000000 + 1 gives 2147483648
3000000000.0 + 1 gives 3000000001

This issue was introduced in PHP 5.2.1 and has not been addressed as of
5.2.6.  5.2.0 and earlier worked as expected.  It also appears to work
properly on Windows.

Reproduce code:
---------------
# the output should be the same as the input
print 3000000000 . "\n";

# these two should be the same
print 3000000000 + 1 . "\n";
print 3000000000.0 + 1 ."\n";


Expected result:
----------------
3000000000
3000000001
3000000001


Actual result:
--------------
2147483647
2147483648
3000000001


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45068&edit=1

Reply via email to