Skip to content

Commit 3ac34fc

Browse files
thestingerManishearth
authored andcommitted
clearly define int and uint to fix unsoundness
This fixes the gap in the language definition causing rust-lang#18726 by defining a clear bound on the maximum size for libraries to enforce. Closes rust-lang#18069
1 parent 3f45250 commit 3ac34fc

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

reference.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,17 +3557,14 @@ The machine types are the following:
35573557

35583558
#### Machine-dependent integer types
35593559

3560-
The Rust type `uint` [^rustuint] is an
3561-
unsigned integer type with target-machine-dependent size. Its size, in
3562-
bits, is equal to the number of bits required to hold any memory address on
3563-
the target machine.
3564-
3565-
The Rust type `int` [^rustint] is a two's complement signed integer type with
3566-
target-machine-dependent size. Its size, in bits, is equal to the size of the
3567-
rust type `uint` on the same target machine.
3568-
3569-
[^rustuint]: A Rust `uint` is analogous to a C99 `uintptr_t`.
3570-
[^rustint]: A Rust `int` is analogous to a C99 `intptr_t`.
3560+
The `uint` type is an unsigned integer type with the same number of bits as the
3561+
platform's pointer type. It can represent every memory address in the process.
3562+
3563+
The `int` type is a signed integer type with the same number of bits as the
3564+
platform's pointer type. The theoretical upper bound on object and array size
3565+
is the maximum `int` value. This ensures that `int` can be used to calculate
3566+
differences between pointers into an object or array and can address every byte
3567+
within an object along with one byte past the end.
35713568

35723569
### Textual types
35733570

0 commit comments

Comments
 (0)