File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -Coverflow-checks=off
1
2
#![ allow( arithmetic_overflow) ]
2
3
3
4
pub fn main ( ) {
4
- // This tests that do (not) do sign extension properly when loading integers
5
+ // This tests that we do (not) do sign extension properly when loading integers
5
6
assert_eq ! ( u32 :: MAX as i64 , 4294967295 ) ;
6
7
assert_eq ! ( i32 :: MIN as i64 , -2147483648 ) ;
7
8
8
9
assert_eq ! ( i8 :: MAX , 127 ) ;
9
10
assert_eq ! ( i8 :: MIN , -128 ) ;
10
11
12
+ // Shifts with negative offsets are subtle.
13
+ assert_eq ! ( 13 << -2i8 , 13 << 254 ) ;
14
+ assert_eq ! ( 13 << i8 :: MIN , 13 ) ;
15
+ assert_eq ! ( 13 << -1i16 , 13 << u16 :: MAX ) ;
16
+ assert_eq ! ( 13 << i16 :: MIN , 13 ) ;
17
+ assert_eq ! ( 13i128 << -2i8 , 13i128 << 254 ) ;
18
+ assert_eq ! ( 13i128 << i8 :: MIN , 13 ) ;
19
+ assert_eq ! ( 13i128 << -1i16 , 13i128 << u16 :: MAX ) ;
20
+ assert_eq ! ( 13i128 << i16 :: MIN , 13 ) ;
21
+
11
22
assert_eq ! ( i32 :: from_str_radix( "A" , 16 ) , Ok ( 10 ) ) ;
12
23
13
24
let n = -0b1000_0000i8 ;
You can’t perform that action at this time.
0 commit comments