[php-src] Issue #21593: JIT if condition optimization leads to flipped result: true is false and false is true

From: Date: Wed, 01 Apr 2026 13:22:52 +0000
Subject: [php-src] Issue #21593: JIT if condition optimization leads to flipped result: true is false and false is true
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251881@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/21593 Author: paulmhh ### Description The following code: ```php <?php declare(strict_types=1); $a = new stdClass(); $a->a = 'a'; if (!empty($a?->a)) { echo 'OK'; } else { echo 'ERROR'; } echo PHP_EOL; ``` run with: php -dopcache.enable=1 -dopcache.enable_cli=1 -dopcache.jit=1205 ./file.php will result in ERROR while plain php ./file.php will result in OK tested with: ``` docker run --rm -ti -v ./jitIssue.php:/jitIssue.php php:8.5 php -dopcache.enable=1 -dopcache.enable_cli=1 -dopcache.jit=1205 /jitIssue.php docker run --rm -ti -v ./jitIssue.php:/jitIssue.php php:8.4 php -dopcache.enable=1 -dopcache.enable_cli=1 -dopcache.jit=1205 /jitIssue.php ``` (it seems php8.3 is not affected) The issue seems to be a negated empty with a null-safe operator inside, only in an if condition. if (!empty($a?->a)) => fails if (empty($a?->a)) => works if (!empty($a->a)) => works $result = !empty($a?->a) => works ### PHP Version ```plain PHP 8.4.19 (cli) (built: Mar 16 2026 22:25:56) (NTS) Copyright (c) The PHP Group Built by https://github.com/docker-library/php Zend Engine v4.4.19, Copyright (c) Zend Technologies with Zend OPcache v8.4.19, Copyright (c), by Zend Technologies and PHP 8.5.4 (cli) (built: Mar 16 2026 22:25:19) (NTS) Copyright (c) The PHP Group Built by https://github.com/docker-library/php Zend Engine v4.5.4, Copyright (c) Zend Technologies with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies ``` ### Operating System _No response_

« previous php.bugs (#251881) next »