File tree Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- f0c4da49983aa699f715caf681e3154b445fb60b
1+ 45660949132222ba7ec0905649b2affd68e0e13c
Original file line number Diff line number Diff line change 11#![ feature( core_intrinsics) ]
22fn main ( ) {
33 // divison of MIN by -1
4- unsafe { std:: intrinsics:: exact_div ( i64:: MIN , -1 ) ; } //~ ERROR result of dividing MIN by -1 cannot be represented
4+ unsafe { std:: intrinsics:: exact_div ( i64:: MIN , -1 ) ; } //~ ERROR overflow in signed remainder ( dividing MIN by -1)
55}
Original file line number Diff line number Diff line change 1+ #![ feature( platform_intrinsics, repr_simd) ]
2+
3+ extern "platform-intrinsic" {
4+ pub ( crate ) fn simd_div < T > ( x : T , y : T ) -> T ;
5+ }
6+
7+ #[ repr( simd) ]
8+ #[ allow( non_camel_case_types) ]
9+ struct i32x2 ( i32 , i32 ) ;
10+
11+ fn main ( ) { unsafe {
12+ let x = i32x2 ( 1 , i32:: MIN ) ;
13+ let y = i32x2 ( 1 , -1 ) ;
14+ simd_div ( x, y) ; //~ERROR Undefined Behavior: overflow in signed division
15+ } }
Original file line number Diff line number Diff line change 11#![ feature( core_intrinsics) ]
22fn main ( ) {
33 // MIN/-1 cannot be represented
4- unsafe { std:: intrinsics:: unchecked_div ( i16:: MIN , -1 ) ; } //~ ERROR overflow executing `unchecked_div`
4+ unsafe { std:: intrinsics:: unchecked_div ( i16:: MIN , -1 ) ; } //~ ERROR overflow in signed division (dividing MIN by -1)
55}
Original file line number Diff line number Diff line change @@ -116,6 +116,9 @@ pub fn main() {
116116 assert_eq ! ( 100i8 . wrapping_rem( 10 ) , 0 ) ;
117117 assert_eq ! ( ( -128i8 ) . wrapping_rem( -1 ) , 0 ) ;
118118
119+ assert_eq ! ( i32 :: MIN . wrapping_div( -1 ) , i32 :: MIN ) ;
120+ assert_eq ! ( i32 :: MIN . wrapping_rem( -1 ) , 0 ) ;
121+
119122 assert_eq ! ( 100i8 . wrapping_neg( ) , -100 ) ;
120123 assert_eq ! ( ( -128i8 ) . wrapping_neg( ) , -128 ) ;
121124
You can’t perform that action at this time.
0 commit comments