-
Notifications
You must be signed in to change notification settings - Fork 290
clarify what is UB #149
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
Merged
Merged
clarify what is UB #149
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dfb93b2
UB
RalfJung 1dcafde
list more ptr offset computations
RalfJung 280761a
NonNull, NonZero*
RalfJung 86d9e2c
Define 'producing'
RalfJung 3241c00
handle recursion in the heading
RalfJung 909b14c
subsume the NonNull things as library types
RalfJung f59eca2
be more precise about dangling
RalfJung 738a338
stick to broader UB for raw ptr offsets/derefs for now
RalfJung 0f51082
avoid redundant UB
RalfJung efb5086
add more cases of UB
RalfJung df5ff63
mention !
RalfJung c41d492
explain when metadata is invalid
RalfJung 1f613d8
Apply suggestions from code review
RalfJung c73730b
raw ptrs must be initialized like integers
RalfJung bd6215e
resolve some nits
RalfJung 7386b5c
refactor null a bit
RalfJung 864625f
fold uninit integer rule with reading uninit memory
RalfJung 64bf0a5
fix def.n of dangling
RalfJung 86a89ae
clarify dangling
RalfJung c5778a1
drop parenthetical
RalfJung 7703c18
some edits
RalfJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,19 @@ to your program. You definitely *should not* invoke Undefined Behavior. | |
Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core | ||
language cares about is preventing the following things: | ||
|
||
* Dereferencing null, dangling, or unaligned pointers | ||
* Dereferencing null, dangling, or unaligned references or raw pointers | ||
* Performing out-of-bounds arithmetic for the computation of a struct/tuple | ||
field address | ||
* Reading [uninitialized memory][] | ||
* Breaking the [pointer aliasing rules][] | ||
* Producing invalid primitive values: | ||
* dangling/null references | ||
* Producing/obtaining invalid primitive values: | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* dangling/null/unaligned references | ||
* null `fn` pointers | ||
* a `bool` that isn't 0 or 1 | ||
* an undefined `enum` discriminant | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* a `char` outside the ranges [0x0, 0xD7FF] and [0xE000, 0x10FFFF] | ||
* A non-utf8 `str` | ||
* a non-utf8 `str` | ||
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. reword for consistency:
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. Or maybe we want to skip this entirely because this is just a library invariant? |
||
* a compound type (`enum`/`struct`/array/tuple) with an invalid field | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Unwinding into another language | ||
* Causing a [data race][race] | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.