-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.F-untagged_unions`#![feature(untagged_unions)]``#![feature(untagged_unions)]`
Description
For example, after laundering interior mutability through a union, a resulting constant undergoes promotion:
#![feature(untagged_unions)]
use std::cell::Cell;
pub const CELL: Option<Cell<u32>> = {
union U { i: u32, c: Cell<u32> }
Some(unsafe { U { i: 0 }.c })
};
fn main() {
let _ = &CELL;
}
error[E0080]: it is undefined behavior to use this value
--> u.rs:9:1
|
9 | fn main() {
| ^^^^^^^^^ type validation failed at .<deref>.<enum-variant(Some)>.0.value: encountered `UnsafeCell` in a `const`
...
@rustbot label +A-const-eval +F-untagged_unions
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-bugCategory: This is a bug.Category: This is a bug.F-untagged_unions`#![feature(untagged_unions)]``#![feature(untagged_unions)]`