-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed as not planned
Labels
C-bugCategory: This is a bug.Category: This is a bug.
Description
The documentation for addr_of_mut!
says:
Note, however, that the
expr
inaddr_of_mut!(expr)
is still subject to all the usual rules. In particular,addr_of_mut!(*ptr::null_mut())
is Undefined Behavior because it dereferences a null pointer.
However, in the example for Creating a pointer to uninitialized data
it shows this code:
let f1_ptr = unsafe { ptr::addr_of_mut!((*uninit.as_mut_ptr()).field) };
In that example it appears as though expr
contains a dereference of uninitialized data, which is not normally valid. That seems in conflict with the earlier warning that "all the usual rules" apply.
I'm guessing that maybe dereferencing is allowed in expr
as long as the pointer isn't dangling?
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.