Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -7742,6 +7742,7 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32
ir_ref is_nan = ir_NE(dval, dval);
ir_ref if_val = ir_IF(is_nan);
ir_IF_TRUE_cold(if_val);
jit_SET_EX_OPLINE(jit, opline);
ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_nan_coerced_to_type_warning));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This file doesn't indent branches anywhere, not sure it makes sense to start a new convention for 2 lines. 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, I did it so that I could understand what is going on, but can remove the indent :)

ir_MERGE_WITH_EMPTY_FALSE(if_val);

Expand Down
6 changes: 3 additions & 3 deletions ext/opcache/tests/jit/nan_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ for ($i = 0; $i < 3; $i++) {
}
?>
--EXPECTF--
Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 4
nan is true

Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 4
nan is true

Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 4
nan is true
16 changes: 8 additions & 8 deletions ext/opcache/tests/jit/nan_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ opcache.protect_memory=1
<?php
function test(float $a) {
if ($a) var_dump("1");
if (!$a) var_dump("2");
if (!$a) var_dump("2");
var_dump((bool) $a);
var_dump(!$a);
echo "\n";
}
function test1(float $a, bool $b) {
var_dump($a && $b); //JMPNZ_EX
var_dump($a && $b); //JMPNZ_EX
}
function test2(float $a, bool $b) {
var_dump($a || $b); // JMPZ_EX
Expand All @@ -34,15 +34,15 @@ test2(1.0, false);
test2(0.0, false);
?>
--EXPECTF--
Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 3
string(1) "1"

Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 4

Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 5
bool(true)

Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 6
bool(false)

string(1) "1"
Expand All @@ -54,13 +54,13 @@ bool(false)
bool(true)


Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 10
bool(true)
bool(true)
bool(false)


Warning: unexpected NAN value was coerced to bool in %s on line %d
Warning: unexpected NAN value was coerced to bool in %s on line 13
bool(true)
bool(true)
bool(false)