php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65304 Use of max int in array_sum
Submitted: 2013-07-21 09:37 UTC Modified: 2013-07-21 12:12 UTC
From: koushky at gmail dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 5.4.17 OS: Ubuntu 13.04 64bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: koushky at gmail dot com
New email:
PHP Version: OS:

 

 [2013-07-21 09:37 UTC] koushky at gmail dot com
Description:
------------
If we add amount of max INT with number 1 in array_sum function , the result will 
be false.

While if we add this two via plus (+) operator ,the result will be true.

My operation system is 64 bit.

Test script:
---------------
/* max INT in 64bit = 9223372036854775807 */

var_dump(array_sum(array(9223372036854775807,1)));

var_dump(9223372036854775807+1);

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

float(9.2233720368548E+18)

Actual result:
--------------
float(9.2233720368548E+18)

float(9.2233720368548E+18)

Patches

bug65304.patch (last revision 2013-07-21 12:11 UTC by laruence@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-21 09:47 UTC] koushky at gmail dot com
update
 [2013-07-21 12:11 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug65304.patch
Revision:   1374408685
URL:        https://bugs.php.net/patch-display.php?bug=65304&patch=bug65304.patch&revision=1374408685
 [2013-07-21 12:12 UTC] laruence@php.net
use fast_add_function here fixed the in-consistent.
 [2013-07-21 13:07 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3380de9774551964af976aa48328e7e6f9bd78ff
Log: Fixed bug #65304 (Use of max int in array_sum)
 [2013-07-21 13:07 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2013-10-31 09:12 UTC] thuhc at yahoo dot com
This bug still happen on ARM 64bits (aarch64)

================================================================================
/root/php-5.5.4/ext/standard/tests/array/bug65304.phpt
================================================================================
int(-9223372036854775808)
float(9.2233720368548E+18)
================================================================================
001+ int(-9223372036854775808)
002- float(%s)
================================================================================
 [2014-10-07 23:17 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=3380de9774551964af976aa48328e7e6f9bd78ff
Log: Fixed bug #65304 (Use of max int in array_sum)
 [2014-10-07 23:29 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=3380de9774551964af976aa48328e7e6f9bd78ff
Log: Fixed bug #65304 (Use of max int in array_sum)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC