php.net |  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-04-10 12:58 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-10 13:22 UTC] tony2001@php.net
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-2019 The PHP Group
All rights reserved.
Last updated: Thu Mar 21 01:01:30 2019 UTC