[interp] relop result is always int (mono/mono#18114)
authorBernhard Urban-Forster <lewurm@gmail.com>
Tue, 10 Dec 2019 21:06:48 +0000 (22:06 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Dec 2019 21:06:48 +0000 (22:06 +0100)
This can lead to problems on big endian.

```
result.i = (int) 1;
--> 0x0000_0001_XXXX_XXXX;

result.l = (long) 1;
--> 0x0000_0000_0000_0001;
```

On little endian it's always `0x0000_0000_0000_0001`, so it doesn't matter.

Commit migrated from https://github.com/mono/mono/commit/a65b7af6d5abf00d7be1f0e85c219657686e33c3

src/mono/mono/mini/interp/transform.c

index 999fc26..9379f37 100644 (file)
@@ -6829,7 +6829,7 @@ cfold_failed:
        case opcode: \
                g_assert (sp [0].val.type == stack_type && sp [1].val.type == stack_type); \
                result.type = STACK_VALUE_I4; \
-               result.field = (cast_type) sp [0].val.field relop (cast_type) sp [1].val.field; \
+               result.i = (cast_type) sp [0].val.field relop (cast_type) sp [1].val.field; \
                break;