The Not ! operator in combination with NAN fails with OPcache enabled

未关闭
#15,773 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
php
领域
compilers

调研方向

使用 PHP 8.3.11 或其他受影响的版本,在启用和禁用 OPcache 的情况下重现报告中的最小 PHP 示例。然后跟踪 OPcache 优化器对比较和取反的处理;当 assertions 通过,并且在启用 OPcache 时两个输出都与预期值匹配,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Bug Category: Optimizer Status: Requires RFC
Description

The following code:

$a = 100.0;
$b = \NAN;

$cmp = $a > $b; // since NAN always false;
$cmp2 = !($a > $b); // $expected true;

var_dump($cmp);
var_dump($cmp2);

assert($cmp === false);
assert($cmp2 === true);

Resulted in this output:

bool(false)
bool(true)

Resulted in this output with opcache enabled:

bool(false)
bool(false) ❌

But I expected this output instead:

bool(false)
bool(true)

The issue only seems to appear using opcache. Also spotted on different environments with older PHP versions.

PHP 8.3.11 (cli) (built: Aug 30 2024 16:21:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

PHP Version

PHP 8.3.11

Operating System

No response

主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。