Bug #76717 [NEW]: var_export() does not create a parsable value for PHP_INT_MIN
| From: | fredemmott@php.net | Date: | Tue, 07 Aug 2018 17:30:11 +0000 |
| Subject: | Bug #76717 [NEW]: var_export() does not create a parsable value for PHP_INT_MIN | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216666@lists.php.net to get a copy of this message | ||
From: fredemmott
Operating system: All
PHP version: 7.3.0beta1
Package: Unknown/Other Function
Bug Type: Bug
Bug description:var_export() does not create a parsable value for PHP_INT_MIN
Description:
------------
var_export() is documented as "Outputs or returns a parsable string
representation of a variable"
It generates an unparseable value for PHP_INT_MIN: it renders it as a
negative decimal.
-x is not a negative literal; it's a unary op on x.
var_export generates '-9223372036854775808' - but as
'9223372036854775808' is greater PHP_INT_MAX, this generates a float.
Test script:
---------------
<?php
var_export(PHP_INT_MIN);
echo "\n";
var_export(PHP_INT_MAX);
echo "\n";
$min = eval('return '.var_export(PHP_INT_MIN, true).';');
$max = eval('return '.var_export(PHP_INT_MAX, true).';');
var_dump($min === PHP_INT_MIN);
var_dump($max === PHP_INT_MAX);
var_dump($min);
var_dump($max);
Expected result:
----------------
The last 4 lines of output should be true, true, (an int: value of
PHP_INT_MIN), (an int: value of PHP_INT_MAX)
Actual result:
--------------
-9223372036854775808
9223372036854775807
bool(false)
bool(true)
float(-9.2233720368548E+18)
int(9223372036854775807)
--
Edit bug report at https://bugs.php.net/bug.php?id=76717&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76717&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76717&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76717&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76717&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76717&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76717&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76717&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76717&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76717&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76717&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76717&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76717&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76717&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76717&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76717&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76717&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76717&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76717&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76717&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76717&r=mysqlcfg