Bitwise AND between c_short and hex value 0x8000 causes range error due to unexpected interpretation of the most-significant bit #22716
Labels
bug
Observed behavior contradicts documented or intended behavior
Zig Version
0.14.0-dev.850+ddcb7b1c1
Steps to Reproduce and Observed Behavior
When returning the bitwise AND between a c_short and a hex value, the most-significant bit is considered out-of-range, despite still being within the bounds of a c_short (u16). As seen in the error message below, this is because I presume the 0x8000 is being converted to the i16 equivalent and then being pushed through bitwise operations (-32767 <= i16 <= 32767).
For example (where _getCurrKeyState(virt_key) returns a c_short):
Error Message:
Expected Behavior
The most-significant bit of a c_short should still be considered within range when bitwise AND operations are taken against it.
The text was updated successfully, but these errors were encountered: