v2 / vlib / v / checker / tests / overflow_int_signed_err.vv
34 lines · 30 sloc · 949 bytes · 9f3f1291e8936cc90c7c1abe66a672ac1173d601
Raw
1const _i8s = [
2 i8(0xff), // converted to -1
3 i8(128), // converted to -128
4 i8(-129), // converted to +127
5 i8(-0xff), // converted to +1
6]
7
8const _i16s = [
9 i16(0xffff), // converted to -1
10 i16(32768), // converted to -32768
11 i16(-32769), // converted to +32767
12 i16(-0xffff), // converted to +1
13]
14
15const _ints = [
16 int(0xffffffff), // converted to -1
17 int(2147483648), // converted to -2147483648 (overflow in 32-bit int)
18 int(-2147483649), // converted to +2147483647 (overflow)
19 int(-0xffffffff), // converted to +1
20]
21
22const _i32s = [
23 i32(0xffffffff), // converted to -1
24 i32(2147483648), // converted to -2147483648
25 i32(-2147483649), // converted to +2147483647
26 i32(-0xffffffff), // converted to +1
27]
28
29const _i64s = [
30 i64(0xffffffffffffffff), // converted to -1
31 i64(9223372036854775808), // converted to -9223372036854775808
32 i64(-9223372036854775809), // converted to +9223372036854775807
33 i64(-0xffffffffffffffff), // converted to +1
34]
35