You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Miscompile: r as *const i32 with r: &i32 reads the value and turns it into a pointer (a facade callback with scalar userdata segfaults in safe code) #1777
Found by the D71 facade work (#1611). Minimal repro:
fn addr(r: &i32) -> *const i32: r as *const i32
fn main:
let x = 42
let p = addr(&x)
print(unsafe { *p })
Expected: 42 (the cast yields the reference's address). Actual: the cast loads the i32 and reinterprets its value as a pointer, so the dereference faults. Through a c facade whose callback userdata is a scalar (&i32), the compiler performs this cast itself, so the segfault happens in safe code. Present on main. The handle tests use a struct userdata to avoid it.
Spec: §15.1 (&T is a reference value), §16.3 (pointer casts). Owner: the cast lowering for &T as *const T (MirLower/codegen), which must take the reference's address value, not load through it.
Activity
D71 facade rulings: ok lists, valid on failed, callback-scope handles…