Add NaN check to IR_NEWREF.

Thanks to Peter Cawley. #1069
This commit is contained in:
Mike Pall
2023-09-09 13:37:31 +02:00
parent 4d05806ae0
commit 7f9907b4ed
2 changed files with 13 additions and 4 deletions

View File

@@ -1739,7 +1739,10 @@ LJFOLD(NE any any)
LJFOLDF(comm_equal)
{
/* For non-numbers only: x == x ==> drop; x ~= x ==> fail */
if (fins->op1 == fins->op2 && !irt_isnum(fins->t))
if (fins->op1 == fins->op2 &&
(!irt_isnum(fins->t) ||
(fleft->o == IR_CONV && /* Converted integers cannot be NaN. */
(uint32_t)(fleft->op2 & IRCONV_SRCMASK) - (uint32_t)IRT_I8 <= (uint32_t)(IRT_U64 - IRT_U8))))
return CONDFOLD(fins->o == IR_EQ);
return fold_comm_swap(J);
}