-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#[repr(C)]
union Foo {
a: u32,
b: i32,
}
const FOO: i32 = unsafe { Foo { a: 15 }.b };
fn main() {
println!("{}", FOO);
}
warning: constant evaluation error: nonexistent struct field
--> src/main.rs:8:18
|
8 | const FOO: i32 = unsafe { Foo { a: 15 }.b };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(const_err)] on by default
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.