Skip to content

Commit 47771d6

Browse files
committed
Auto merge of rust-lang#2173 - RalfJung:rustlib, r=oli-obk
different strategy for normalizing Rust stdlib path `-Zremap-cwd-prefix` has some [unintended side-effects](rust-lang/miri#2172), so we could use regexp-based normalization instead. Unfortunately, this will fail if the user's home directory contains a space. Fixes rust-lang/miri#2172
2 parents 1c11fc6 + 8997db2 commit 47771d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+336
-206
lines changed

cargo-miri/bin.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,7 @@ path = "lib.rs"
461461
command.env_remove("RUSTFLAGS");
462462
// Disable debug assertions in the standard library -- Miri is already slow enough.
463463
// But keep the overflow checks, they are cheap.
464-
// Also remap the current directory to something that is stable across different
465-
// machines. Otherwise ui output would contain the current directory.
466-
command.env(
467-
"RUSTFLAGS",
468-
"-Cdebug-assertions=off -Coverflow-checks=on -Zremap-cwd-prefix=rustc_src",
469-
);
464+
command.env("RUSTFLAGS", "-Cdebug-assertions=off -Coverflow-checks=on");
470465
// Finally run it!
471466
if command.status().expect("failed to run xargo").success().not() {
472467
show_error(format!("failed to run xargo"));

tests/compile-fail/alloc/deallocate-bad-alignment.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
711
note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC
812
--> $DIR/deallocate-bad-alignment.rs:LL:CC
913
|

tests/compile-fail/alloc/deallocate-bad-size.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
711
note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC
812
--> $DIR/deallocate-bad-size.rs:LL:CC
913
|

tests/compile-fail/alloc/deallocate-twice.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
711
note: inside `main` at $DIR/deallocate-twice.rs:LL:CC
812
--> $DIR/deallocate-twice.rs:LL:CC
913
|

tests/compile-fail/alloc/global_system_mixup.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// error-pattern: which is Rust heap memory, using
44

55
// normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
6+
// normalize-stderr-test: "\| +\^+" -> "| ^"
7+
// normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();"
68

79
#![feature(allocator_api, slice_ptr_get)]
810

tests/compile-fail/alloc/global_system_mixup.stderr

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
error: Undefined Behavior: deallocating ALLOC, which is Rust heap memory, using PLATFORM heap deallocation operation
2+
--> RUSTLIB/std/src/sys/PLATFORM/alloc.rs:LL:CC
3+
|
4+
LL | FREE();
5+
| ^ deallocating ALLOC, which is Rust heap memory, using PLATFORM heap deallocation operation
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::sys::PLATFORM::alloc::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at rustc_src/src/sys/PLATFORM/alloc.rs:LL:CC
7-
= note: inside `<std::alloc::System as std::alloc::Allocator>::deallocate` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::sys::PLATFORM::alloc::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/PLATFORM/alloc.rs:LL:CC
11+
= note: inside `<std::alloc::System as std::alloc::Allocator>::deallocate` at RUSTLIB/std/src/alloc.rs:LL:CC
812
note: inside `main` at $DIR/global_system_mixup.rs:LL:CC
913
--> $DIR/global_system_mixup.rs:LL:CC
1014
|
1115
LL | unsafe { System.deallocate(ptr, l); }
12-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
16+
| ^
1317

1418
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1519

tests/compile-fail/alloc/reallocate-bad-size.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::realloc` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
711
note: inside `main` at $DIR/reallocate-bad-size.rs:LL:CC
812
--> $DIR/reallocate-bad-size.rs:LL:CC
913
|

tests/compile-fail/alloc/reallocate-dangling.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::realloc` at rustc_src/src/alloc.rs:LL:CC
10+
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
711
note: inside `main` at $DIR/reallocate-dangling.rs:LL:CC
812
--> $DIR/reallocate-dangling.rs:LL:CC
913
|

tests/compile-fail/alloc/stack_free.stderr

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
2+
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3+
|
4+
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC
7-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at rustc_src/src/alloc.rs:LL:CC
8-
= note: inside `alloc::alloc::box_free::<i32, std::alloc::Global>` at rustc_src/src/alloc.rs:LL:CC
9-
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at rustc_src/src/ptr/mod.rs:LL:CC
10-
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at rustc_src/src/mem/mod.rs:LL:CC
10+
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11+
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
12+
= note: inside `alloc::alloc::box_free::<i32, std::alloc::Global>` at RUSTLIB/alloc/src/alloc.rs:LL:CC
13+
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
14+
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
1115
note: inside `main` at $DIR/stack_free.rs:LL:CC
1216
--> $DIR/stack_free.rs:LL:CC
1317
|

tests/compile-fail/concurrency/too_few_args.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | panic!()
99
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1010
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1111

12-
= note: inside `thread_start` at rustc_src/src/panic.rs:LL:CC
12+
= note: inside `thread_start` at RUSTLIB/std/src/panic.rs:LL:CC
1313
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error: aborting due to previous error; 1 warning emitted

tests/compile-fail/concurrency/too_many_args.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | panic!()
99
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1010
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1111

12-
= note: inside `thread_start` at rustc_src/src/panic.rs:LL:CC
12+
= note: inside `thread_start` at RUSTLIB/std/src/panic.rs:LL:CC
1313
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error: aborting due to previous error; 1 warning emitted

tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let x = unsafe { ptr::addr_of!(*p) };
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99

10-
= note: inside `main` at rustc_src/src/ptr/mod.rs:LL:CC
10+
= note: inside `main` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
1111
= note: this error originates in the macro `ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
1212

1313
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/compile-fail/dangling_pointers/null_pointer_write_zst.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
error: Undefined Behavior: memory access failed: null pointer is not a valid pointer
2+
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
3+
|
4+
LL | copy_nonoverlapping(&src as *const T, dst, 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::write::<[u8; 0]>` at rustc_src/src/ptr/mod.rs:LL:CC
7-
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at rustc_src/src/ptr/mut_ptr.rs:LL:CC
10+
= note: inside `std::ptr::write::<[u8; 0]>` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
11+
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
812
note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
913
--> $DIR/null_pointer_write_zst.rs:LL:CC
1014
|

tests/compile-fail/fs/isolated_file.stderr

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
error: unsupported operation: `open` not available when isolation is enabled
2+
--> RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC
3+
|
4+
LL | let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode as c_int) })?;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `open` not available when isolation is enabled
26
|
37
= help: pass the flag `-Zmiri-disable-isolation` to disable isolation;
48
= help: or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning
59

6-
= note: inside closure at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC
7-
= note: inside `std::sys::PLATFORM::cvt_r::<i32, [closure@std::sys::PLATFORM::fs::File::open_c::{closure#0}]>` at rustc_src/src/sys/PLATFORM/mod.rs:LL:CC
8-
= note: inside `std::sys::PLATFORM::fs::File::open_c` at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC
9-
= note: inside `std::sys::PLATFORM::fs::File::open` at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC
10-
= note: inside `std::fs::OpenOptions::_open` at rustc_src/src/fs.rs:LL:CC
11-
= note: inside `std::fs::OpenOptions::open::<&std::path::Path>` at rustc_src/src/fs.rs:LL:CC
12-
= note: inside `std::fs::File::open::<&str>` at rustc_src/src/fs.rs:LL:CC
10+
= note: inside closure at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC
11+
= note: inside `std::sys::PLATFORM::cvt_r::<i32, [closure@std::sys::PLATFORM::fs::File::open_c::{closure#0}]>` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC
12+
= note: inside `std::sys::PLATFORM::fs::File::open_c` at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC
13+
= note: inside `std::sys::PLATFORM::fs::File::open` at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC
14+
= note: inside `std::fs::OpenOptions::_open` at RUSTLIB/std/src/fs.rs:LL:CC
15+
= note: inside `std::fs::OpenOptions::open::<&std::path::Path>` at RUSTLIB/std/src/fs.rs:LL:CC
16+
= note: inside `std::fs::File::open::<&str>` at RUSTLIB/std/src/fs.rs:LL:CC
1317
note: inside `main` at $DIR/isolated_file.rs:LL:CC
1418
--> $DIR/isolated_file.rs:LL:CC
1519
|

tests/compile-fail/generator-pinned-moved.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: inside `<GeneratorIteratorAdapter<[static generator@$DIR/generator-pinned-
1313
|
1414
LL | match me.resume(()) {
1515
| ^^^^^^^^^^^^^
16-
= note: inside `<std::boxed::Box<GeneratorIteratorAdapter<[static generator@$DIR/generator-pinned-moved.rs:LL:CC]>> as std::iter::Iterator>::next` at rustc_src/src/boxed.rs:LL:CC
16+
= note: inside `<std::boxed::Box<GeneratorIteratorAdapter<[static generator@$DIR/generator-pinned-moved.rs:LL:CC]>> as std::iter::Iterator>::next` at RUSTLIB/alloc/src/boxed.rs:LL:CC
1717
note: inside `main` at $DIR/generator-pinned-moved.rs:LL:CC
1818
--> $DIR/generator-pinned-moved.rs:LL:CC
1919
|

tests/compile-fail/intrinsics/copy_overflow.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
error: Undefined Behavior: overflow computing total size of `copy`
2+
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
3+
|
4+
LL | copy(src, dst, count)
5+
| ^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::intrinsics::copy::<i32>` at rustc_src/src/intrinsics.rs:LL:CC
7-
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::copy_from` at rustc_src/src/ptr/mut_ptr.rs:LL:CC
10+
= note: inside `std::intrinsics::copy::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
11+
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::copy_from` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
812
note: inside `main` at $DIR/copy_overflow.rs:LL:CC
913
--> $DIR/copy_overflow.rs:LL:CC
1014
|

tests/compile-fail/intrinsics/out_of_bounds_ptr_1.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer arithmetic failed: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
2+
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
3+
|
4+
LL | unsafe { intrinsics::offset(self, count) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC
10+
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
711
note: inside `main` at $DIR/out_of_bounds_ptr_1.rs:LL:CC
812
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
913
|

tests/compile-fail/intrinsics/out_of_bounds_ptr_2.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: overflowing in-bounds pointer arithmetic
2+
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
3+
|
4+
LL | unsafe { intrinsics::offset(self, count) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC
10+
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
711
note: inside `main` at $DIR/out_of_bounds_ptr_2.rs:LL:CC
812
--> $DIR/out_of_bounds_ptr_2.rs:LL:CC
913
|

tests/compile-fail/intrinsics/out_of_bounds_ptr_3.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer arithmetic failed: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
2+
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
3+
|
4+
LL | unsafe { intrinsics::offset(self, count) }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC
10+
= note: inside `std::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
711
note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC
812
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
913
|

tests/compile-fail/intrinsics/ptr_offset_0_plus_0.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer arithmetic failed: null pointer is not a valid pointer
2+
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
3+
|
4+
LL | unsafe { intrinsics::offset(self, count) as *mut T }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: null pointer is not a valid pointer
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC
10+
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
711
note: inside `main` at $DIR/ptr_offset_0_plus_0.rs:LL:CC
812
--> $DIR/ptr_offset_0_plus_0.rs:LL:CC
913
|

tests/compile-fail/intrinsics/ptr_offset_int_plus_int.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
error: Undefined Behavior: pointer arithmetic failed: 0x1 is not a valid pointer
2+
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
3+
|
4+
LL | unsafe { intrinsics::offset(self, count) as *mut T }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: 0x1 is not a valid pointer
26
|
37
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
48
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
59

6-
= note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC
10+
= note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
711
note: inside `main` at $DIR/ptr_offset_int_plus_int.rs:LL:CC
812
--> $DIR/ptr_offset_int_plus_int.rs:LL:CC
913
|

0 commit comments

Comments
 (0)