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
#![feature(extern_types)]extern"C"{typeOpaque;}structNewtype(Opaque);structS{i:i32,j:i32,a:Newtype,}fnmain(){let buf = [0i32;4];let x:&Newtype = unsafe{&*(&buf as*const_as*constNewtype)};// Projecting to the newtype works, because it is always at offset 0.let _field = &x.0;let x:&S = unsafe{&*(&buf as*const_as*constS)};// Accessing sized fields is perfectly fine, even at non-zero offsets.let _field = &x.i;let _field = &x.j;// This needs to compute the field offset, but we don't know the type's alignment,// so this panics.let _field = &x.a;//~ERROR: does not have a known offset}
from rustc:
./tests/ui/extern/extern-types-field-offset.rs
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift
Program output
The text was updated successfully, but these errors were encountered: