Reputation: 532
Imagine a self-referential struct (simplified for clarity)
struct Storage {
/// a mutable pointer into memory region owned by `_store`
store: *mut u8,
/// underlying memory buffer
_store: Box<[u8]>,
}
If _store
field is never used directly after being initialized, is it possible for rust/llvm compiler to optimize it away? If so what will happen to store
, will it be a dangling pointer or something more outrageous? :)
Upvotes: 0
Views: 45