Bug #80742 [Opn->Ver]: Opcache JIT makes some boolean logic unexpectedly be true

From: Date: Tue, 16 Feb 2021 11:10:24 +0000
Subject: Bug #80742 [Opn->Ver]: Opcache JIT makes some boolean logic unexpectedly be true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232182@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80742&edit=1

 ID:                 80742
 Updated by:         nikic@php.net
 Reported by:        dktapps at pmmp dot io
 Summary:            Opcache JIT makes some boolean logic unexpectedly be
                     true
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            JIT
 Operating System:   Windows 10
 PHP Version:        8.0Git-2021-02-13 (Git)
-Assigned To:        
+Assigned To:        dmitry
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2021-02-13 00:47:35] dktapps at pmmp dot io

Description:
------------
JIT breaks some boolean logic involving and in ways I don't understand.

It's possible this occurs with other operators, but I stumbled on this in code in the wild so I
haven't tested further.

When running the following using -dopcache.jit=0 (or without opcache), the script produces the
expected result.

Using -dopcache.jit=1205 produces the broken result.

This occurs in a minimal NTS build with only PHP and OPcache using https://github.com/php/php-src/commit/6ec25f386ff058b5ecda6f11c5f62e934b31f660,
so it's easily reproducible.



Test script:
---------------
<?php

function checkGroundState(float $movY, float $dy) : void{
	var_dump($movY != $dy, $movY < 0, ($movY != $dy and $movY < 0));
	var_dump("wow!");
}

checkGroundState(0, 0);

Expected result:
----------------
bool(false)
bool(false)
bool(false)
string(4) "wow!"


Actual result:
--------------
bool(false)
bool(false)
bool(true)
string(4) "wow!"



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80742&edit=1


Thread (3 messages)

« previous php.bugs (#232182) next »