Bug #81627 [Opn->Nab]: Incorrect result of php
| From: | requinix@php.net | Date: | Tue, 16 Nov 2021 23:24:03 +0000 |
| Subject: | Bug #81627 [Opn->Nab]: Incorrect result of php | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237798@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81627&edit=1
ID: 81627
Updated by: requinix@php.net
Reported by: shaohua dot li at inf dot ethz dot ch
Summary: Incorrect result of php
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Ubuntu 20.04.3 LTS
PHP Version: 8.1Git-2021-11-16 (Git)
Block user comment: N
Private report: N
New Comment:
> $a &= $a-- + $a;
That statements has two modifications to $a: the -- and the &=. PHP does not guarantee in what
order those will happen.
https://en.wikipedia.org/wiki/Sequence_point
Previous Comments:
------------------------------------------------------------------------
[2021-11-16 15:49:06] shaohua dot li at inf dot ethz dot ch
Description:
------------
Hi there,
I compiled php-src twice with clang13 -O0 and -O2 (default). However, for the following code sample,
the two
./sapi/cli/php would evaluate it differently.
For "clang13 -O0" compiled one, "bug" would be printed. However, "clang13
-O2" wouldn't.
Test script:
---------------
<?php
function test() {
$n = $a = 0;
while($a <= 0) {
$a &= $a-- + $a;
if (++$n > 59) die("bug\n");
}
}
test();
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81627&edit=1