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
calling e.g. mem::uninitialized::() causes immediate undefined behavior for returning a bool that is not definitely either true or false. Worse, truly uninitialized memory like what gets returned here is special in that the compiler knows that it does not have a fixed value. This makes it undefined behavior to have uninitialized data in a variable even if that variable has an integer type. (Notice that the rules around uninitialized integers are not finalized yet, but until they are, it is advisable to avoid them.)
Despite mentioning that it is deprecated, the guide seems to equate it to MaybeUninit and allow it if justified:
The std::mem::uninitialized function (deprecated 1.38) or the std::mem::MaybeUninit type (stabilized 1.36) must not be used, or explicitly justified when necessary.
It goes on to say
std::mem::MaybeUninit is an improvement over std::mem::uninitialized. In-deed, it makes dropping uninitialized values a lot more difficult.
Which might give the impression that that is the only difference, when in fact std::mem::uninitialized is a lot more UB-happy (And I think I've heard a couple times that it cannot be used without UB (Unless it's used to make a MaybeUninit or a similar unsafe union with a unit variant))
The text was updated successfully, but these errors were encountered:
The Documentation says
Despite mentioning that it is deprecated, the guide seems to equate it to MaybeUninit and allow it if justified:
It goes on to say
Which might give the impression that that is the only difference, when in fact std::mem::uninitialized is a lot more UB-happy (And I think I've heard a couple times that it cannot be used without UB (Unless it's used to make a MaybeUninit or a similar unsafe union with a unit variant))
The text was updated successfully, but these errors were encountered: