Closed
Description
The following code worked up until nightly-2018-07-30-x86_64-unknown-linux-gnu
:
pub union Transmute<T:Copy, U:Copy> {
pub from:T,
pub to:U,
}
#[derive(Clone,Copy)]
struct Foo(i64);
static FOO:Foo = unsafe { Transmute { from:0 }.to };
fn main() {
}
error[E0080]: this static likely exhibits undefined behavior
--> src/main.rs:9:1
|
9 | static FOO:Foo = unsafe { Transmute { from:0 }.to };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered undefined bytes at .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
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.