Skip to content

Const-time immutability does not carry over to runtime #4410

@BennoLossin

Description

@BennoLossin

I tried this code:

#![feature(sync_unsafe_cell)]
use std::cell::SyncUnsafeCell;

static PARAM: SyncUnsafeCell<i64> = SyncUnsafeCell::new(0);

static BAD: &'static i64 = unsafe { &*PARAM.get() };

fn main() {
    println!("{BAD}");
    unsafe { *PARAM.get() = 42 };
    println!("{BAD}");
}

And expected miri to complain about UB. But it doesn't (I also tried tree-borrows & strict-provenance).

Zulip discussion.

(feel free to improve the issue title)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-spec-questionCategory: it is unclear what the intended behavior of Miri for this case is

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions