🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: php.bugs
Article #1

[php-src] Issue #18563: NAN in array compare

#1
From: mvorisek
Date: Thu, 15 May 2025 09:46
47 lines
3260 bytes
Issue: https://github.com/php/php-src/issues/18563
Author: mvorisek

### Description

The following code:

```php
<?php

$a = [NAN];
$b = $a;
var_dump($a === $b);

$a = [NAN];
$b = [NAN];
var_dump($a === $b);
```

Resulted in this output:
```
bool(true)
bool(false)
```

But I expected this output instead:
```
bool(true)
bool(true)
```
(or both false)

online repro: https://3v4l.org/CVGBt

I understand the reason - in the 1st case, the zval reference is the same, thus used for the comparison, which is valid for all values excl. NAN. In the 2nd case, zval references are not the same, thus all array items are compared and because currently NAN === NAN returns false, the result is false.

Because of this compare behaviour inconsistency I propose to fix this by changing the result of NAN === NAN to be true. At least in when in arrays.

### PHP Version

```plain
any
```

### Operating System

any
Technical Details
Message-ID: <rwsCo4ms61mWi1LAsKEDfJ8TIWI7GqRDVallHsJGQ@master.php.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!news.php.net

Show Full Headers
Complete Article Headers
Message-ID: <rwsCo4ms61mWi1LAsKEDfJ8TIWI7GqRDVallHsJGQ@master.php.net>
Subject: [php-src] Issue #18563: NAN in array compare
Date: Thu, 15 May 2025 09:46:20 +0000
From: noreply@php.net (mvorisek)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!news.php.net
Newsgroups: php.bugs
Followup-To: php.internals
X-Original-To: php-bugs@lists.php.net
Delivered-To: php-bugs@lists.php.net
Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5])
 by lists.php.net (Postfix) with ESMTPS id C51B51A00BC
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
 t=1747301593; bh=vNIo9kIQytT6VrwFsrIEykGrPYvSliVF7n7JiRGnVsg=;
 h=Date:To:From:Subject:From;
 b=aMIZ0UI+rcWwKwWT+ahw4Lw3sDqJPBW3O34AyisIfsIrgg/9wk2b7Hdn+jKIOkyKF
 KB/PCAeStSZ0l+4vpYh0pDyNjpKb/9YUGWJ+o52X6LYZ6mdF7eSCO38InQiwF7uBEy
 z6qMfJWLcRyu0H/bTV4PYhsoRHqVhD+cwu/GzybjcE9wpeonSUT3NNi66ZDytJMvkX
 cVfq2HVz08JkJ+s9+wmhgiJR27zg0Emw/TLgocpd6D7gWVd4mSngehbSJDNOCFDvqv
 IW7+kIwqthzNUdAdy56cjIyrhLijtNkbgZBBDZHly6+0fABALCgj3NzSRohLKuQSMn
 3AJy/ZnpHQLQw==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
 by php-smtp4.php.net (Postfix) with ESMTP id 877AA180390
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Status: No, score=-1.5 required=5.0 tests=ALL_TRUSTED,BAYES_05
 autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: Error (Cannot connect to unix socket
 '/var/run/clamav/clamd.ctl': connect: Connection refused)
X-Envelope-From: <noreply@php.net>
Received: from master.php.net (main.php.net [142.93.197.176])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by php-smtp4.php.net (Postfix) with ESMTPS
To: php-bugs@lists.php.net
X-Mailer: PHPMailer 6.4.0 (https://github.com/PHPMailer/PHPMailer)
Precedence: bulk
List-help: <mailto:php-bugs+help@lists.php.net
List-unsubscribe: <mailto:php-bugs+unsubscribe@lists.php.net>
List-post: <mailto:php-bugs@lists.php.net>
List-Id: php-bugs.lists.php.net
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8