Bug #80732 [NEW]: large integer operating addition error when overflow
| From: | 809721719 at qq dot com | Date: | Thu, 11 Feb 2021 16:30:05 +0000 |
| Subject: | Bug #80732 [NEW]: large integer operating addition error when overflow | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-232068@lists.php.net to get a copy of this message | ||
From: 809721719 at qq dot com
Operating system: MacOS 10.14 (64bit)
PHP version: 7.4.15
Package: *General Issues
Bug Type: Bug
Bug description:large integer operating addition error when overflow
Description:
------------
The addition of two integers exceeds the maximum value of the integer.
After an overflow occurs, the resulting value is distorted.
I test in C/C++/Go and got different results from PHP, but they get the
same results.
Test script:
---------------
var_dump(intval(9223372036854775807 + 1));
// int(-9223372036854775808)
var_dump(intval(9223372036854775807 + 2));
// int(-9223372036854775808)
var_dump(intval(9223372036854775807 + 3));
// int(-9223372036854775808)
Expected result:
----------------
int(-9223372036854775808)
int(-9223372036854775807)
int(-9223372036854775806)
Actual result:
--------------
int(-9223372036854775808)
int(-9223372036854775808)
int(-9223372036854775808)
--
Edit bug report at https://bugs.php.net/bug.php?id=80732&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80732&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80732&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80732&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80732&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80732&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80732&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80732&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80732&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80732&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80732&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80732&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80732&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80732&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80732&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80732&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80732&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80732&r=mysqlcfg