forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#80900 - camelid:readpointerasbytes-ice, r=o…
…li-obk Fix ICE with `ReadPointerAsBytes` validation error Fixes rust-lang#79690. r? `````@oli-obk`````
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ignore-32bit | ||
// This test gives a different error on 32-bit architectures. | ||
|
||
union Transmute<T: Copy, U: Copy> { | ||
t: T, | ||
u: U, | ||
} | ||
trait Bar { | ||
fn bar(&self) -> u32; | ||
} | ||
struct Foo { | ||
foo: u32, | ||
bar: bool, | ||
} | ||
impl Bar for Foo { | ||
fn bar(&self) -> u32 { | ||
self.foo | ||
} | ||
} | ||
#[derive(Copy, Clone)] | ||
struct Fat<'a>(&'a Foo, &'static VTable); | ||
struct VTable { | ||
size: Foo, | ||
} | ||
const FOO: &dyn Bar = &Foo { | ||
foo: 128, | ||
bar: false, | ||
}; | ||
const G: Fat = unsafe { Transmute { t: FOO }.u }; | ||
//~^ ERROR it is undefined behavior to use this value | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0080]: it is undefined behavior to use this value | ||
--> $DIR/issue-79690.rs:29:1 | ||
| | ||
LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered read of part of a pointer at .1.<deref>.size.foo | ||
| | ||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |