|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41038 Problem with PHP parser in handling MIN_INT value.
Submitted: 2007-04-10 12:58 UTC Modified: 2007-04-10 13:22 UTC
From: mahesh dot vemula at in dot ibm dot com Assigned:
Status: Wont fix Package: *Compile Issues
PHP Version: 5CVS-2007-04-10 (snap) OS: RHEL 4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
50 - 30 = ?
Subscribe to this entry?

 [2007-04-10 12:58 UTC] mahesh dot vemula at in dot ibm dot com
The least integer value (i.e -2147483648 ) is  being treated as float(-2147483648) by the parser. var_dump(-2147483648) returns float(-2147483648).  A integer value should be treated as float, only if the value is beyond the boundary of the integer type. 
The php documentation explains the same here :  &

The Reproduce code confirms that the parser is not handling the Minimum Integer value (i.e, -2147483648) as expected. 

Operating System: RHEL 4
Linux Kernel : Linux 2.6.9
PHP Version: PHP 5.2 (Built on Apr 10, 2007 from
PHP Configure Setup: ./configure

Reproduce code:
$i = -2147483648;

$j = (int)"-2147483648";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-10 13:22 UTC]
String "-2147483648" contains two tokens: "-" and "2147483648".
Since strtol() returns ERANGE when parsing "2147483648", the result number is double.
From what I can see, changing this fact would require major changes to the parser which hopefully nobody is going to do.
Marking as "Won't fix".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 13:01:29 2024 UTC