Edit report at https://bugs.php.net/bug.php?id=69693&edit=1
ID: 69693
Updated by: danack@php.net
Reported by: bugs at tmarques dot com
Summary: Reproducible Corruption on Variables
-Status: Open
+Status: Feedback
Type: Bug
Package: *General Issues
Operating System: Linux x32
PHP Version: 5.5.25
Block user comment: N
Private report: N
New Comment:
"two variables that have integers get summed and return a float."
Yes - this is the defined behaviour for when an operation occurs and the result is no longer
representable as an integer type. e.g.
<?php
$x = PHP_INT_MAX;
$x += 1;
var_dump($x);
?>
Will say that $x is a float value. Or to quote from the manual - http://php.net/manual/en/language.types.integer.php
"If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a
float instead. Also, an operation which results in a number beyond the bounds of the integer type
will return a float instead."
If you think the conversion from int to float is occurring inappropriately, please can you provide a
simple reproduction case?
Previous Comments:
------------------------------------------------------------------------
[2015-05-22 18:47:44] bugs at tmarques dot com
P.S. I would look into this further but have no idea where to look for the problem or how to debug
PHP internal's. Looking for some input and happy to help with testing in any way I can.
------------------------------------------------------------------------
[2015-05-22 18:39:05] bugs at tmarques dot com
Description:
------------
This is a bug I ran into when using Wordpress normally. After running a script for a while on a x32
ABI php, it enters an infinite loop that exhausts process memory. Upon investigation, two variables
that have integers get summed and return a float. Depending on the input text, the loop doesn't
trigger the bug.
This doesn't happen on i386/i686, haven't tested on x86-64.
Test script:
---------------
Please see both examples at:
https://gist.github.com/anonymous/4320f460cd1e4144df2a
Relevant code is "run.php" from lines 96 to 120.
It never triggers if I copy the $text variable to another one that's not even used ($_test).
It also returns the correct sum for a test in the code as:
if ( is_float( $i + $l ) === TRUE )
So I have to sum and check if the value is big (it usually returns some float of E+18 magnitude).
Expected result:
----------------
Integer variables sum and result in an integer.
Actual result:
--------------
Sum of two integers returns a float.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69693&edit=1