Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix right shift c codegen bug. (#5919)
* fix right shift c codegen bug. signed int must first be cast as unsigned before converting to larger integer. The C compiler will auto convert operands to the largest type.
- Loading branch information
1 parent
199f061
commit da52ade
Showing
2 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
discard """ | ||
output: '''''' | ||
""" | ||
|
||
proc T() = | ||
let VI = -8 | ||
let VI64 = -8'i64 | ||
let VI32 = -8'i32 | ||
let VI16 = -8'i16 | ||
let VI8 = -8'i8 | ||
doAssert( (VI shr 1) == 9223372036854775804) | ||
doAssert( (VI64 shr 1) == 9223372036854775804) | ||
doAssert( (VI32 shr 1) == 2147483644) | ||
doAssert( (VI16 shr 1) == 32764) | ||
doAssert( (VI8 shr 1) == 124) | ||
|
||
|
||
T() |