[php-src] Issue #8418: The influence of opcache on the behavior of enum cases.

From: Date: Thu, 21 Apr 2022 13:32:05 +0000
Subject: [php-src] Issue #8418: The influence of opcache on the behavior of enum cases.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241126@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8418 Author: SerafimArts ### Description The following code: ```php <?php class ExampleClass { public const EXAMPLE_CONST= 42; } enum ExampleEnum: int { case ENUM_CASE = ExampleClass::EXAMPLE_CONST; } var_dump(ExampleEnum::ENUM_CASE->value); ``` Resulted in this output: ``` $ php test.php -dopcache.jit_buffer_size=0 -dopcache.enable=1 -dopcache.enable_cli=0 // - First execution: 42 // - Second execution: 42 // - Third execution: 42 $ php test.php -dopcache.jit_buffer_size=0 -dopcache.enable=1 -dopcache.enable_cli=1 // - First execution: 42 // - Second execution: Enum case value must be compile-time evaluatable // - Third execution: Enum case value must be compile-time evaluatable ``` But I expected this output instead: ``` // - First execution: 42 // - Second execution: 42 // - Third execution: 42 ``` ### Conclusion - Behavior is affected by enabling or disabling opcache. - The jit buffer is disabled, which disables JIT compilation and therefore the problem occurs at an earlier "compilation stage". ### Environment Linux (Debian-based) ```sh PHP 8.1.4 (cli) (built: Apr 4 2022 13:30:33) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.4, Copyright (c) Zend Technologies with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies ``` ### Other Info 1) Perhaps the issue has been resolved by https://github.com/php/php-src/pull/8190 2) This issue has been moved from another https://github.com/php/php-src/issues/7821 ### PHP Version 8.1.4 ### Operating System Ubuntu Budgie 21.10

« previous php.bugs (#241126) next »