0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.5004: right shift on negative number does not work as documented

Problem:    Right shift on negative number does not work as documented.
Solution:   Use a uvarnumber_T type cast.
This commit is contained in:
Bram Moolenaar
2022-05-22 20:16:32 +01:00
parent a061f34191
commit 338bf58eba
7 changed files with 26 additions and 19 deletions

View File

@@ -4096,12 +4096,7 @@ exec_instructions(ectx_T *ectx)
case EXPR_RSHIFT: if (arg2 > MAX_LSHIFT_BITS)
res = 0;
else
{
res = arg1 >> arg2;
// clear the topmost sign bit
res &= ~((uvarnumber_T)1
<< MAX_LSHIFT_BITS);
}
res = (uvarnumber_T)arg1 >> arg2;
break;
default: break;
}