Skip to content
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

Fix note about undefined behavior #2632

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/unsafe-rust/unsafe-functions/calling.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ Key points:
- The second argument to `slice::from_raw_parts` is the number of _elements_,
not bytes! This example demonstrates unexpected behavior by reading past the
end of one array and into another.
- This is not actually undefined behaviour, as `KeyPair` has a defined
representation (due to `repr(C)`) and no padding, so the contents of the
second array is also valid to read through the same pointer.
- This is undefined behavior because we're reading past the end of the array
that the pointer was derived from.
- `log_public_key` should be unsafe, because `pk_ptr` must meet certain
prerequisites to avoid undefined behaviour. A safe function which can cause
undefined behaviour is said to be `unsound`. What should its safety
Expand Down