diff options
| author | Ralf Jung <post@ralfj.de> | 2023-08-02 16:14:36 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-08-02 18:51:50 +0200 |
| commit | 7767cbb3b0b332fd0a46e347ea7f68f20109d768 (patch) | |
| tree | 4e748496f86ac3de86d85a83f65bafc6f85eb0f1 /src | |
| parent | 7637653b9fdd2b2f2dc3b378891eb5cf6aea9f5d (diff) | |
| download | rust-7767cbb3b0b332fd0a46e347ea7f68f20109d768.tar.gz rust-7767cbb3b0b332fd0a46e347ea7f68f20109d768.zip | |
const validation: point at where we found a pointer but expected an integer
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/diagnostics.rs | 4 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/validity/uninit_float.stderr | 4 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/validity/uninit_integer.stderr | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index 8d9901807ec..6bd4be91e51 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -273,6 +273,8 @@ pub fn report_error<'tcx, 'mir>( } else { #[rustfmt::skip] let title = match e.kind() { + UndefinedBehavior(UndefinedBehaviorInfo::ValidationError(e)) if matches!(e.kind, ValidationErrorKind::PointerAsInt { .. } | ValidationErrorKind::PartialPointer) => + bug!("This validation error should be impossible in Miri: {:?}", e.kind), UndefinedBehavior(_) => "Undefined Behavior", ResourceExhaustion(_) => @@ -377,7 +379,7 @@ pub fn report_error<'tcx, 'mir>( if let Some((alloc_id, access)) = extra { eprintln!( "Uninitialized memory occurred at {alloc_id:?}{range:?}, in this allocation:", - range = access.uninit, + range = access.bad, ); eprintln!("{:?}", ecx.dump_alloc(alloc_id)); } diff --git a/src/tools/miri/tests/fail/validity/uninit_float.stderr b/src/tools/miri/tests/fail/validity/uninit_float.stderr index 677a0fc5570..e95e3b18128 100644 --- a/src/tools/miri/tests/fail/validity/uninit_float.stderr +++ b/src/tools/miri/tests/fail/validity/uninit_float.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: constructing invalid value at .value[0]: encountered uninitialized bytes +error: Undefined Behavior: constructing invalid value at .value[0]: encountered uninitialized memory, but expected a floating point number --> $DIR/uninit_float.rs:LL:CC | LL | let _val: [f32; 1] = unsafe { std::mem::uninitialized() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .value[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .value[0]: encountered uninitialized memory, but expected a floating point number | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/validity/uninit_integer.stderr b/src/tools/miri/tests/fail/validity/uninit_integer.stderr index a9ac2a6dc67..2156886cd71 100644 --- a/src/tools/miri/tests/fail/validity/uninit_integer.stderr +++ b/src/tools/miri/tests/fail/validity/uninit_integer.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: constructing invalid value at .value[0]: encountered uninitialized bytes +error: Undefined Behavior: constructing invalid value at .value[0]: encountered uninitialized memory, but expected an integer --> $DIR/uninit_integer.rs:LL:CC | LL | let _val = unsafe { std::mem::MaybeUninit::<[usize; 1]>::uninit().assume_init() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .value[0]: encountered uninitialized bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .value[0]: encountered uninitialized memory, but expected an integer | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information |
