@@ -41,15 +41,16 @@ They have the same layout as the [pointer types] for which the pointee is
41
41
> ` unsigned ` is at least as large as a short, allowed to have padding bits, etc.
42
42
> but it is not necessarily pointer-sized.
43
43
44
- The layout of ` usize ` determines the following:
44
+ The layout of ` usize ` determine the following:
45
45
46
- - the maximum size of Rust objects (` size_of ` and ` size_of_val ` return ` usize ` ),
46
+ - the maximum size of Rust values (` size_of ` and ` size_of_val ` return ` usize ` ),
47
47
- the maximum number of elements in an array (` [T; N: usize] ` ),
48
- - how much a pointer of a certain type can be offseted (limited by ` usize::max_value( )` ).
48
+ - how much a pointer of a certain type can be offseted (` ptr.add(count: usize )` ).
49
49
50
- The maximum size of any single value must fit within ` usize ` to [ ensure that
51
- pointer diff is
52
- representable] ( https://github.com/rust-rfcs/unsafe-code-guidelines/pull/5#discussion_r212703192 ) .
50
+ > ** Note** : in the current Rust implementation the maximum size of Rust values
51
+ > is limited to ` isize::max_value() ` . The LLVM ` getelementptr ` instruction uses
52
+ > signed-integer field offsets. Rust calls ` getelementptr ` with the ` inbounds `
53
+ > flag which assumes that field offsets do not overflow.
53
54
54
55
[ pointer types ] : ./pointers.md
55
56
@@ -74,6 +75,7 @@ the corresponding C fixed-width integer types are expected.
74
75
The specification of native C integer types, ` char ` , ` short ` , ` int ` , ` long ` ,
75
76
... as well as their ` unsigned ` variants, guarantees a lower bound on their size,
76
77
e.g., ` short ` is _ at least_ 16-bit wide and _ at least_ as wide as ` char ` .
78
+
77
79
Their exact sizes are _ implementation-defined_ .
78
80
79
81
Libraries like ` libc ` use knowledge of this _ implementation-defined_ behavior on
0 commit comments