ID:               50970
 Updated by:       [email protected]
 Reported By:      zhangsilly at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.2.12
 New Comment:

You need a true 64-bit OS if you want this to work.  The integer 
datatype in PHP is a long.  Your example works perfectly on 64-bit 
Linux.  We can't fix this on 32-bit without turning the basic integer 
datatype into some sort of arbitrary precision hack which would 
probably be an order of magnitude performance hit for basic integer 
math.  And frankly, the number of 32-bit web servers is falling at a 
rapid rate.


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

[2010-02-21 01:32:40] zhangsilly at gmail dot com

This bug is still exists in the svn version.

Hope you will test this code:

echo '3740925952' + 1; //output 3740925953
echo (int) '3740925952' + 1; // output 2147483648

This bug is unacceptable.

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

[2010-02-20 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2010-02-16 13:53:22] zhangsilly at gmail dot com

To jani:

   Your PHP works fine on linux. Is your OS 64bit?

   I 'am sure , On Windows 32Bit, both of strtol and atol will truncate
the value.

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

[2010-02-16 13:37:20] zhangsilly at gmail dot com

Thanks for your reply. For I am having my spring festeval, now my
computer does'nt have a compiler, I can't test it.

    But I do download the source from
http://snaps.php.net/php5.2-latest.tar.gz  at 2010-02-16 21:19, chinese
standard time, and check the source , I 'am sure the bug can be
reproduced.

    See the file Zend/zend_operators.c, this bug is caused by the
function:

ZEND_API void convert_to_long_base(zval *op, int base)
{
        char *strval;
        long tmp;

        switch (op->type) {
                case IS_NULL:
                        op->value.lval = 0;
                        break;
                case IS_RESOURCE: {
                                TSRMLS_FETCH();

                                zend_list_delete(op->value.lval);
                        }
                        /* break missing intentionally */
                case IS_BOOL:
                case IS_LONG:
                        break;
                case IS_DOUBLE:
                        DVAL_TO_LVAL(op->value.dval, op->value.lval);
                        break;
                case IS_STRING:
                        strval = op->value.str.val;
                        op->value.lval = strtol(strval, NULL, base);
                        STR_FREE(strval);
                        break;

     See the enter point IS_STRING, it use strtol directly. The
truncate was caused by the strtol. If you still use it directly, This
bug will not be fixed.

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

[2010-02-12 17:36:08] [email protected]

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works fine for me with Linux..

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/50970

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

Reply via email to