Skip to content

Commit

Permalink
Merge pull request #154 from gnzlbg/usize16
Browse files Browse the repository at this point in the history
Document that isize/usize are at least 16-bit wide on all platforms we currently support
  • Loading branch information
RalfJung authored Jul 25, 2019
2 parents 103a2b5 + d8d7edb commit 401e559
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions reference/src/layout/scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ 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. All
> platforms we currently support have a C platform, and as a consequence,
> `isize`/`usize` are at least 16-bit wide for all of them.
> **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

0 comments on commit 401e559

Please sign in to comment.