c2compiler
c2compiler copied to clipboard
Incorrect cast behaviour in LiteralAnalyser
- cast
(3) => will cast the expression to a 31 bit integer. - cast
(2147483648) => 0 - cast
(2147483647) => -1 - cast
(1073741823) = 1073741823 - cast
(1073741824) = -1073741824
The cast is using getIntegerWidth to set the resulting width, causing this issue.
Which syntax do you use exactly then? Because currently cast needs a generics-like argument, like:
cast<u32>(2147483648)
It's in the implicit casts in the LiteralAnalyser when mixing uXX with iXX values.