-
Notifications
You must be signed in to change notification settings - Fork 533
update aliasing rules section of the reference #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,15 @@ code. | |
* Evaluating a [dereference expression] (`*expr`) on a raw pointer that is | ||
[dangling] or unaligned, even in [place expression context] | ||
(e.g. `addr_of!(&*expr)`). | ||
* Breaking the [pointer aliasing rules]. `&mut T` and `&T` follow LLVM’s scoped | ||
[noalias] model, except if the `&T` contains an [`UnsafeCell<U>`]. | ||
* Breaking the [pointer aliasing rules]. `Box<T>`, `&mut T` and `&T` follow LLVM’s | ||
scoped noalias model, except if the `&T` contains an [`UnsafeCell<U>`]. | ||
References must not be dangling while they are live. (The exact liveness | ||
duration is not specified, but it is certainly upper-bounded by the syntactic | ||
lifetime assigned by the borrow checker. When a reference is passed to a | ||
function, it is live at least as long as that function call, again except if | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... Does this apply to Because it's obviously safe to deallocate a
|
||
the `&T` contains an [`UnsafeCell<U>`].) All this also applies when values of | ||
these types are passed in a (nested) field of a compound type, but not behind | ||
pointer indirections. | ||
* Mutating immutable data. All data inside a [`const`] item is immutable. Moreover, all | ||
data reached through a shared reference or data owned by an immutable binding | ||
is immutable, unless that data is contained within an [`UnsafeCell<U>`]. | ||
|
Uh oh!
There was an error while loading. Please reload this page.