Fix comparing pointers and integers

See #189
This commit is contained in:
Alexander Batalov 2023-05-24 21:52:50 +03:00
parent 70b0b61664
commit 62c5c4757c
1 changed files with 6 additions and 6 deletions

View File

@ -932,7 +932,7 @@ static void opConditionalOperatorNotEqual(Program* program)
result = value[1].integerValue != value[0].integerValue; result = value[1].integerValue != value[0].integerValue;
break; break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
result = (intptr_t)(value[1].integerValue) != (intptr_t)(value[0].pointerValue); result = (uintptr_t)(value[1].integerValue) != (uintptr_t)(value[0].pointerValue);
break; break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
@ -941,7 +941,7 @@ static void opConditionalOperatorNotEqual(Program* program)
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
switch (value[0].opcode) { switch (value[0].opcode) {
case VALUE_TYPE_INT: case VALUE_TYPE_INT:
result = (intptr_t)(value[1].pointerValue) != (intptr_t)(value[0].integerValue); result = (uintptr_t)(value[1].pointerValue) != (uintptr_t)(value[0].integerValue);
break; break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
result = value[1].pointerValue != value[0].pointerValue; result = value[1].pointerValue != value[0].pointerValue;
@ -1028,7 +1028,7 @@ static void opConditionalOperatorEqual(Program* program)
result = value[1].integerValue == value[0].integerValue; result = value[1].integerValue == value[0].integerValue;
break; break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
result = (intptr_t)(value[1].integerValue) == (intptr_t)(value[0].pointerValue); result = (uintptr_t)(value[1].integerValue) == (uintptr_t)(value[0].pointerValue);
break; break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
@ -1037,7 +1037,7 @@ static void opConditionalOperatorEqual(Program* program)
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
switch (value[0].opcode) { switch (value[0].opcode) {
case VALUE_TYPE_INT: case VALUE_TYPE_INT:
result = (intptr_t)(value[1].pointerValue) == (intptr_t)(value[0].integerValue); result = (uintptr_t)(value[1].pointerValue) == (uintptr_t)(value[0].integerValue);
break; break;
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
result = value[1].pointerValue == value[0].pointerValue; result = value[1].pointerValue == value[0].pointerValue;
@ -1131,7 +1131,7 @@ static void opConditionalOperatorLessThanEquals(Program* program)
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
switch (value[0].opcode) { switch (value[0].opcode) {
case VALUE_TYPE_INT: case VALUE_TYPE_INT:
result = (intptr_t)value[1].pointerValue <= (intptr_t)value[0].integerValue; result = (uintptr_t)value[1].pointerValue <= (uintptr_t)value[0].integerValue;
break; break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");
@ -1385,7 +1385,7 @@ static void opConditionalOperatorGreaterThan(Program* program)
case VALUE_TYPE_PTR: case VALUE_TYPE_PTR:
switch (value[0].opcode) { switch (value[0].opcode) {
case VALUE_TYPE_INT: case VALUE_TYPE_INT:
result = (intptr_t)value[1].pointerValue > (intptr_t)value[0].integerValue; result = (uintptr_t)value[1].pointerValue > (uintptr_t)value[0].integerValue;
break; break;
default: default:
assert(false && "Should be unreachable"); assert(false && "Should be unreachable");