Closed tstreiff closed 4 years ago
I suspect that this comes from semantics/on_number(). This function tries to determine the smaller integer type able to hold the value of a constant. For this it uses the maximum value possible for each integer type (computed in context/limit_max()) The comparison should be "<=" instead of "<" because the maximum value is part of the value supported by a type. In our case, for 0xffffffff, on_number() returns "long" (64bit) whereas it should return "unsigned int" (32bit). This leads to the erroneous extension from 32bit to 64bit.
Tests passed !
For the 1st comparison, a i32 comparison is generated which is correct:
For the 2nd one, a i32 to i64 cast is generated on x before the comparison is made with 0xffffffff, which is wrong:
0xffffffff is a valid constant for an i32, there is no need for the i64 cast.