@@ -35,7 +35,8 @@ of `char` is _implementation-defined_.
35
35
36
36
The ` isize ` and ` usize ` types are pointer-sized signed and unsigned integers.
37
37
They have the same layout as the [ pointer types] for which the pointee is
38
- ` Sized ` , and are layout compatible with C's ` uintptr_t ` and ` intptr_t ` types.
38
+ ` Sized ` , and are layout compatible with C's ` uintptr_t ` and ` intptr_t ` types,
39
+ and are therefore at least 16-bit wide.
39
40
40
41
> ** Note** : Rust's ` usize ` and C's ` unsigned ` types are ** not** equivalent. C's
41
42
> ` unsigned ` is at least as large as a short, allowed to have padding bits, etc.
@@ -59,6 +60,19 @@ They have the same layout as the [pointer types] for which the pointee is
59
60
> These limits have not gone through the RFC process and are not guaranteed to
60
61
> hold.
61
62
63
+ <details ><summary ><b >Rationale</b ></summary >
64
+
65
+ C99 [ 7.18.2.4] ( https://port70.net/~nsz/c/c99/n1256.html#7.18.2.4 ) "Limits of
66
+ integer types capable of holding object pointers" provides the following minimum
67
+ range of values that the pointer-holding integer types must support:
68
+
69
+ * ` intptr_t ` : ` [INTPTR_MIN, INTPTR_MAX] = [-(2^15 - 1), 2^15 - 1] `
70
+ * ` uintptr_t ` : ` [0, UINTPTR_MAX] = [0, 2^16 - 1] `
71
+
72
+ That is, ` isize ` /` usize ` are at least 16-bit wide.
73
+
74
+ </details >
75
+
62
76
[ pointer types ] : ./pointers.md
63
77
64
78
## Fixed-width integer types
0 commit comments