diff options
author | Parashurama <Rhagdamaziel@ymail.com> | 2017-05-31 21:05:14 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-05-31 21:05:14 +0200 |
commit | da52ade86e9df306b03958c5525a0e6973fc1cb5 (patch) | |
tree | 7db91b0a8ed79f1ee85c2480028d15b213579f5f /tests/arithm | |
parent | 199f061ddc8ac69bfc619670c50ebddfb6ed0fee (diff) | |
download | Nim-da52ade86e9df306b03958c5525a0e6973fc1cb5.tar.gz |
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.
Diffstat (limited to 'tests/arithm')
-rw-r--r-- | tests/arithm/tshr.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/arithm/tshr.nim b/tests/arithm/tshr.nim new file mode 100644 index 000000000..09e6e570c --- /dev/null +++ b/tests/arithm/tshr.nim @@ -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() |