Closed
Description
Creating this issue to track this FIXME note in float formatting:
This is calling
get_muton an uninitialized
MaybeUninit(here and elsewhere in this file). Revisit this once
we decided whether that is valid or not.
We can do this only because we are libstd and coupled to the compiler.
(FWIW, usingfreezewould not be enough;flt2dec::Partis an enum!)
The issue being mentioned when the fixme was closed without addressing this concern, and the new tracking issue doesn't raise it, so created this so that we can discuss it here and link it to the tracking issue
cc @RalfJung
Activity
[-]Validity of get_mut on MaybeUninit[/-][+]Validity of get_mut/assume_init_mut on MaybeUninit[/+]RalfJung commentedon Aug 30, 2020
Besides the float code, there's also the
Readcode doing something similar for allowing reads into uninitialized buffers. However, rust-lang/rfcs#2930 should resolve that I think.danielhenrymantilla commentedon Aug 30, 2020
Could we rename it to validity of
.assume_init_mut()on uninitializedfloat(s)? or&muton uninitialized floats?Regarding the issue at hand, obviously only
libstdand other internal crates can rely on the internals of therustcit is released with, so technically, we could go ahead with #76047 and "ignore" the FIXME, as long as we have this issue to remind us of fixing that.Doing so is not that bad as when I attempted to tackle #66174, since by now we have initiatives such as the one I suggested there having been implemented in a library crate, using a library version of out references, and we also have the aforementioned RFC getting some progress. So this time, letting the FIXME without fixing it yet is not just a "useless procrastination of the problem", it is a meaningful "wait for the required language feature", I'd say 🙂
RalfJung commentedon Aug 30, 2020
The issue is not really specific to floats, it is tight to whether references are allowed to refer to uninitialized data.
So this is basically the rustc side of (a part of) rust-lang/unsafe-code-guidelines#77.
[-]Validity of get_mut/assume_init_mut on MaybeUninit[/-][+]Validity of MaybeUninit::get_mut/assume_init_mut on invalid data[/+]RalfJung commentedon Aug 30, 2020
Agreed for the
Readside. For the float usage, really that code should be converted to raw pointers.[-]Validity of MaybeUninit::get_mut/assume_init_mut on invalid data[/-][+]Fix incorrect use of MaybeUninit::assume_init_mut in standard library[/+][-]Fix incorrect use of MaybeUninit::assume_init_mut in standard library[/-][+]Fix incorrect use of MaybeUninit::assume_init_mut in flt2dec[/+]RalfJung commentedon Sep 2, 2020
Actually, let's use #42788 for the
Readpart (there's another FIXME in the code referencing that already).This is just for flt2dec, and will be fixed by #76241.
Auto merge of rust-lang#76241 - RalfJung:flt2dec, r=Mark-Simulacrum