#41038 [Opn->WFx]: Problem with PHP parser in handling MIN_INT value.
| From: | tony2001@php.net | Date: | Tue, 10 Apr 2007 13:22:52 +0000 |
| Subject: | #41038 [Opn->WFx]: Problem with PHP parser in handling MIN_INT value. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111289@lists.php.net to get a copy of this message | ||
ID: 41038
Updated by: tony2001@php.net
Reported By: mahesh dot vemula at in dot ibm dot com
-Status: Open
+Status: Wont fix
Bug Type: *Compile Issues
Operating System: RHEL 4
PHP Version: 5CVS-2007-04-10 (snap)
New Comment:
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".
Previous Comments:
------------------------------------------------------------------------
[2007-04-10 12:58:00] mahesh dot vemula at in dot ibm dot com
Description:
------------
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 :
http://in.php.net/manual/en/function.intval.php
&
http://in.php.net/manual/en/language.types.integer.php
Remarks:
The Reproduce code confirms that the parser is not handling the Minimum
Integer value (i.e, -2147483648) as expected.
Environment:
Operating System: RHEL 4
Linux Kernel : Linux 2.6.9
PHP Version: PHP 5.2 (Built on Apr 10, 2007 from snaps.php.net)
PHP Configure Setup: ./configure
Reproduce code:
---------------
<?php
$i = -2147483648;
var_dump($i);
$j = (int)"-2147483648";
var_dump($j);
?>
Expected result:
----------------
int(-2147483648)
int(-2147483648)
Actual result:
--------------
float(-2147483648)
int(-2147483648)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41038&edit=1