Skip to content

Flow based const qualification is unsound when combined with mut references / raw pointer deref #90124

Closed
@tmiasko

Description

@tmiasko

For example, the constant C is presumed not to need drop (the example can be easily adapted to other qualifs & situations):

#![feature(const_mut_refs)]
#![feature(const_precise_live_drops)]
#![feature(const_swap)]

pub const C: Option<String> = {
    let mut x = None;
    let mut y = Some(String::new());
    let a = &mut x;
    let b = &mut y;
    std::mem::swap(a, b);
    std::mem::forget(y);
    x
};

pub const D: () = {
    C;
};

@rustbot label +A-const-eval +A-const-fn +F-const_mut_refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)F-const_mut_refs`#![feature(const_mut_refs)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions