Skip to content

Document that isize/usize are at least 16-bit wide on all platforms we currently support #154

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 6 commits into from
Jul 25, 2019
Merged
Changes from 5 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
6 changes: 6 additions & 0 deletions reference/src/layout/scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ The `isize` and `usize` types are pointer-sized signed and unsigned integers.
They have the same layout as the [pointer types] for which the pointee is
`Sized`, and are layout compatible with C's `uintptr_t` and `intptr_t` types.

> **Note**: C99 [7.18.2.4](https://port70.net/~nsz/c/c99/n1256.html#7.18.2.4)
> requires `uintptr_t` and `intptr_t` to be at least 16-bit wide. That is, on
> all platforms that we currently support, which have a C platform,
> `isize`/`usize` are at least 16-bit wide. Currently, `libcore` unconditionally
> provides impls of `From<i16>`/`From<u16>` for `isize`/`usize`.

> **Note**: Rust's `usize` and C's `unsigned` types are **not** equivalent. C's
> `unsigned` is at least as large as a short, allowed to have padding bits, etc.
> but it is not necessarily pointer-sized.
Expand Down