Bug #75938 [NEW]: Modulus value not stored in variable
| From: | php at darkain dot com | Date: | Thu, 08 Feb 2018 19:55:58 +0000 |
| Subject: | Bug #75938 [NEW]: Modulus value not stored in variable | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213870@lists.php.net to get a copy of this message | ||
From: php at darkain dot com
Operating system: Debian 9.3
PHP version: 7.2.2
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Modulus value not stored in variable
Description:
------------
Using this combination of code, $mod remains INT 0 instead of being set
to INT 1. The wrapped var_dump however shows the proper value still.
I've tested this code on my Debian box with:
PHP 7.2.2-1+0~20180205160742.18+stretch~1.gbpb78b58
On my test machine, php cli works properly. However, php fpm shows this
particular error.
My guess is that this is somewhere in the optimizer. Changing or
removing any line prior to the first var_dump will result in proper
output. Changing the values from variables to constant will result in
proper output. Changing the modulus operator to any other operator will
result in a proper output.
Test script:
---------------
function borken($columns) {
$columns = (int) $columns;
if ($columns < 1) return 0;
$count = count([1,2,3,4,5]);
var_dump($mod = ($count % $columns));
var_dump($mod);
}
borken(2);
Expected result:
----------------
int(1)
int(1)
Actual result:
--------------
int(1)
int(0)
--
Edit bug report at https://bugs.php.net/bug.php?id=75938&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75938&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75938&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75938&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75938&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75938&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75938&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75938&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75938&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75938&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75938&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75938&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75938&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75938&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75938&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75938&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75938&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75938&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75938&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75938&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75938&r=mysqlcfg