Add pointer vs int equality check

This commit is contained in:
Alexander Batalov 2022-07-23 07:42:33 +03:00
parent f3869e0acf
commit 757330bff4
1 changed files with 6 additions and 0 deletions

View File

@ -995,12 +995,18 @@ static void opConditionalOperatorEqual(Program* program)
case VALUE_TYPE_INT: case VALUE_TYPE_INT:
result = value[1].integerValue == value[0].integerValue; result = value[1].integerValue == value[0].integerValue;
break; break;
case VALUE_TYPE_PTR:
result = (intptr_t)(value[1].integerValue) == (intptr_t)(value[0].pointerValue);
break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
} }
break; break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
switch (value[0].opcode) { switch (value[0].opcode) {
case VALUE_TYPE_INT:
result = (intptr_t)(value[1].pointerValue) == (intptr_t)(value[0].integerValue);
break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
result = value[1].pointerValue == value[0].pointerValue; result = value[1].pointerValue == value[0].pointerValue;
break; break;