diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-04-26 15:57:47 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-04-26 14:24:35 -0400 |
| commit | 9ec4ccc68f6473ce4f02fc5d2b87ad92e2eb555a (patch) | |
| tree | e11ad31594fe66fcfa449960f4b128ec9315d93e /test | |
| parent | 4df2f3d74f140ae6a60dc33d3e0fb7b25f29d5b9 (diff) | |
| download | zig-9ec4ccc68f6473ce4f02fc5d2b87ad92e2eb555a.tar.gz zig-9ec4ccc68f6473ce4f02fc5d2b87ad92e2eb555a.zip | |
Do not invoke UB in BigInt shr operations
Shifting a value of type T by an amount that's greater or equal to the
size of the type itself is UB.
Spotted by @tgschultz
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage1/behavior/bit_shifting.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/stage1/behavior/bit_shifting.zig b/test/stage1/behavior/bit_shifting.zig index c638ec1709..1877c8cdcb 100644 --- a/test/stage1/behavior/bit_shifting.zig +++ b/test/stage1/behavior/bit_shifting.zig @@ -90,7 +90,9 @@ fn testShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, c // #2225 test "comptime shr of BigInt" { comptime { - var n = 0xdeadbeef0000000000000000; - std.debug.assert(n >> 64 == 0xdeadbeef); + var n0 = 0xdeadbeef0000000000000000; + std.debug.assert(n0 >> 64 == 0xdeadbeef); + var n1 = 17908056155735594659; + std.debug.assert(n1 >> 64 == 0); } } |
