check for overflow when doing pointer arithmetic
This commit is contained in:
8
tests/compile-fail/ptr_offset_overflow.rs
Normal file
8
tests/compile-fail/ptr_offset_overflow.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
//error-pattern: overflowing math on a pointer
|
||||
fn main() {
|
||||
let v = [1i8, 2];
|
||||
let x = &v[1] as *const i8;
|
||||
// One of them is guaranteed to overflow
|
||||
let _ = unsafe { x.offset(isize::max_value()) };
|
||||
let _ = unsafe { x.offset(isize::min_value()) };
|
||||
}
|
||||
Reference in New Issue
Block a user