mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
validate raw wide pointers
This commit is contained in:
parent
92e75c0f88
commit
96baf1c54e
@ -379,16 +379,23 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::RawPtr(..) => {
|
ty::RawPtr(..) => {
|
||||||
|
// Check pointer part.
|
||||||
if self.ref_tracking_for_consts.is_some() {
|
if self.ref_tracking_for_consts.is_some() {
|
||||||
// Integers/floats in CTFE: For consistency with integers, we do not
|
// Integers/floats in CTFE: For consistency with integers, we do not
|
||||||
// accept undef.
|
// accept undef.
|
||||||
let _ptr = try_validation!(value.to_scalar_ptr(),
|
let _ptr = try_validation!(value.to_scalar_ptr(),
|
||||||
"undefined address in raw pointer", self.path);
|
"undefined address in raw pointer", self.path);
|
||||||
let _meta = try_validation!(value.to_meta(),
|
|
||||||
"uninitialized data in raw fat pointer metadata", self.path);
|
|
||||||
} else {
|
} else {
|
||||||
// Remain consistent with `usize`: Accept anything.
|
// Remain consistent with `usize`: Accept anything.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check metadata.
|
||||||
|
let meta = try_validation!(value.to_meta(),
|
||||||
|
"uninitialized data in wide pointer metadata", self.path);
|
||||||
|
let layout = self.ecx.layout_of(value.layout.ty.builtin_deref(true).unwrap().ty)?;
|
||||||
|
if layout.is_unsized() {
|
||||||
|
self.check_wide_ptr_meta(meta, layout)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ if ty.is_box() || ty.is_region_ptr() => {
|
_ if ty.is_box() || ty.is_region_ptr() => {
|
||||||
// Handle wide pointers.
|
// Handle wide pointers.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// ignore-tidy-linelength
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
@ -28,7 +29,9 @@ struct BadSliceRepr {
|
|||||||
union SliceTransmute {
|
union SliceTransmute {
|
||||||
repr: SliceRepr,
|
repr: SliceRepr,
|
||||||
bad: BadSliceRepr,
|
bad: BadSliceRepr,
|
||||||
|
addr: usize,
|
||||||
slice: &'static [u8],
|
slice: &'static [u8],
|
||||||
|
raw_slice: *const [u8],
|
||||||
str: &'static str,
|
str: &'static str,
|
||||||
my_str: &'static MyStr,
|
my_str: &'static MyStr,
|
||||||
my_slice: &'static MySliceBool,
|
my_slice: &'static MySliceBool,
|
||||||
@ -59,7 +62,9 @@ union DynTransmute {
|
|||||||
repr: DynRepr,
|
repr: DynRepr,
|
||||||
repr2: DynRepr2,
|
repr2: DynRepr2,
|
||||||
bad: BadDynRepr,
|
bad: BadDynRepr,
|
||||||
|
addr: usize,
|
||||||
rust: &'static dyn Trait,
|
rust: &'static dyn Trait,
|
||||||
|
raw_rust: *const dyn Trait,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Trait {}
|
trait Trait {}
|
||||||
@ -72,39 +77,37 @@ struct MyStr(str);
|
|||||||
struct MySlice<T: ?Sized>(bool, T);
|
struct MySlice<T: ?Sized>(bool, T);
|
||||||
type MySliceBool = MySlice<[bool]>;
|
type MySliceBool = MySlice<[bool]>;
|
||||||
|
|
||||||
|
// # str
|
||||||
// OK
|
// OK
|
||||||
const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str};
|
const STR_VALID: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str};
|
||||||
// bad str
|
// bad str
|
||||||
const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
const STR_TOO_LONG: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
// bad str
|
// bad str
|
||||||
const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
const STR_LENGTH_PTR: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
// bad str in user-defined unsized type
|
// bad str in user-defined unsized type
|
||||||
const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
const MY_STR_LENGTH_PTR: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
|
// invalid UTF-8
|
||||||
|
const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
// invalid UTF-8 in user-defined str-like
|
||||||
|
const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
|
// # slice
|
||||||
// OK
|
// OK
|
||||||
const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice};
|
const SLICE_VALID: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice};
|
||||||
// bad slice
|
// bad slice: length uninit
|
||||||
const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
const SLICE_LENGTH_UNINIT: &[u8] = unsafe { SliceTransmute { addr: 42 }.slice};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
// bad slice
|
// bad slice: length too big
|
||||||
const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
const SLICE_TOO_LONG: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
// bad slice: length not an int
|
||||||
// bad trait object
|
const SLICE_LENGTH_PTR: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
||||||
const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
|
||||||
// bad trait object
|
|
||||||
const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
|
||||||
// bad trait object
|
|
||||||
const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
|
||||||
|
|
||||||
// bad data *inside* the trait object
|
|
||||||
const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
// bad data *inside* the slice
|
// bad data *inside* the slice
|
||||||
@ -120,12 +123,33 @@ const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false
|
|||||||
const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
// invalid UTF-8
|
// # raw slice
|
||||||
const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
const RAW_SLICE_VALID: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.raw_slice}; // ok
|
||||||
|
const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.raw_slice}; // ok because raw
|
||||||
|
const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { SliceTransmute { addr: 42 }.raw_slice};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
// invalid UTF-8 in user-defined str-like
|
|
||||||
const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
// # trait object
|
||||||
|
// bad trait object
|
||||||
|
const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
// bad trait object
|
||||||
|
const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
// bad trait object
|
||||||
|
const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
|
// bad data *inside* the trait object
|
||||||
|
const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
||||||
|
// # raw trait object
|
||||||
|
const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 0 } }.rust};
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.raw_rust};
|
||||||
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl } as *const _; // ok because raw
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
@ -1,101 +1,29 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/union-ub-fat-ptr.rs:78:1
|
--> $DIR/ub-wide-ptr.rs:84:1
|
||||||
|
|
|
|
||||||
LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
LL | const STR_TOO_LONG: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds)
|
||||||
|
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/union-ub-fat-ptr.rs:81:1
|
--> $DIR/ub-wide-ptr.rs:87:1
|
||||||
|
|
|
|
||||||
LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
LL | const STR_LENGTH_PTR: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
|
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/union-ub-fat-ptr.rs:84:1
|
--> $DIR/ub-wide-ptr.rs:90:1
|
||||||
|
|
|
|
||||||
LL | const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
|
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/union-ub-fat-ptr.rs:90:1
|
--> $DIR/ub-wide-ptr.rs:94:1
|
||||||
|
|
|
||||||
LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds)
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:93:1
|
|
||||||
|
|
|
||||||
LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:97:1
|
|
||||||
|
|
|
||||||
LL | const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:100:1
|
|
||||||
|
|
|
||||||
LL | const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:103:1
|
|
||||||
|
|
|
||||||
LL | const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:107:1
|
|
||||||
|
|
|
||||||
LL | const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.<dyn-downcast>, but expected something less or equal to 1
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:111:1
|
|
||||||
|
|
|
||||||
LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }];
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>[0], but expected something less or equal to 1
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:117:1
|
|
||||||
|
|
|
||||||
LL | const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]);
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.0, but expected something less or equal to 1
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:120:1
|
|
||||||
|
|
|
||||||
LL | const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.1[0], but expected something less or equal to 1
|
|
||||||
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
|
||||||
--> $DIR/union-ub-fat-ptr.rs:124:1
|
|
||||||
|
|
|
|
||||||
LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>
|
||||||
@ -103,13 +31,117 @@ LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/union-ub-fat-ptr.rs:127:1
|
--> $DIR/ub-wide-ptr.rs:97:1
|
||||||
|
|
|
|
||||||
LL | const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
LL | const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>.0
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>.0
|
||||||
|
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
error: aborting due to 14 previous errors
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:104:1
|
||||||
|
|
|
||||||
|
LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { SliceTransmute { addr: 42 }.slice};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in wide pointer metadata
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:107:1
|
||||||
|
|
|
||||||
|
LL | const SLICE_TOO_LONG: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds)
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:110:1
|
||||||
|
|
|
||||||
|
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:114:1
|
||||||
|
|
|
||||||
|
LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }];
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>[0], but expected something less or equal to 1
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:120:1
|
||||||
|
|
|
||||||
|
LL | const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.0, but expected something less or equal to 1
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:123:1
|
||||||
|
|
|
||||||
|
LL | const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.1[0], but expected something less or equal to 1
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:129:1
|
||||||
|
|
|
||||||
|
LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { SliceTransmute { addr: 42 }.raw_slice};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in wide pointer metadata
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:134:1
|
||||||
|
|
|
||||||
|
LL | const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:137:1
|
||||||
|
|
|
||||||
|
LL | const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:140:1
|
||||||
|
|
|
||||||
|
LL | const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:144:1
|
||||||
|
|
|
||||||
|
LL | const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.<dyn-downcast>, but expected something less or equal to 1
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:148:1
|
||||||
|
|
|
||||||
|
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 0 } }.rust};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/ub-wide-ptr.rs:150:1
|
||||||
|
|
|
||||||
|
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.raw_rust};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling or unaligned vtable pointer in wide pointer or too small vtable
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||||
|
|
||||||
|
error: aborting due to 18 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
Loading…
Reference in New Issue
Block a user