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
The following code in arena-rs is unsound, because there is no guarantee, that zero-initialized data is a properly initialized T and dereferencing non-properly initialized data is an undefined behavior:
unsafe{*ptr = value;// ...}
The *ptr = value line should be replaced with std::ptr::write(ptr, value).
There is no guarantee that T object is properly aligned and thus there is an another undefined behavior because only a pointer to a properly aligned object can be dereferenced without undefined behavior.
Arena should use std::mem::align_of to obtain information about T alignment, and insert appropriate padding before T.
The following code in arena-rs is unsound, because there is no guarantee, that zero-initialized data is a properly initialized
Tand dereferencing non-properly initialized data is an undefined behavior:The
*ptr = valueline should be replaced withstd::ptr::write(ptr, value).There is no guarantee that
Tobject is properly aligned and thus there is an another undefined behavior because only a pointer to a properly aligned object can be dereferenced without undefined behavior.Arenashould usestd::mem::align_ofto obtain information aboutTalignment, and insert appropriate padding beforeT.