authorgravatar for nathan@nmichaels.orgNathan Michaels <nathan@nmichaels.org> 2019-12-16 23:55:35-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-17 15:44:34-05:00
logf389e5e61fcbc92423c16ccd2d0c79878d1589e4
tree879cc1283c9482ab3292b1ec4e8992dd47ac9aca
parent62c817420df0420e20756b2c3a4ec99db3b5649d

Clarify allowzero's interaction with optional pointers.


1 files changed, 4 insertions(+), 2 deletions(-)

doc/langref.html.in+4-2
...@@ -2133,8 +2133,10 @@ fn foo(bytes: []u8) u32 {...@@ -2133,8 +2133,10 @@ fn foo(bytes: []u8) u32 {
2133 <p>2133 <p>
2134 This pointer attribute allows a pointer to have address zero. This is only ever needed on the2134 This pointer attribute allows a pointer to have address zero. This is only ever needed on the
2135 freestanding OS target, where the address zero is mappable. If you want to represent null pointers, use2135 freestanding OS target, where the address zero is mappable. If you want to represent null pointers, use
2136 {#link|Optional Pointers#} instead. In this code example, if the pointer did not have the2136 {#link|Optional Pointers#} instead. {#link|Optional Pointers#} with {#syntax#}allowzero{#endsyntax#}
2137 {#syntax#}allowzero{#endsyntax#} attribute, this would be a {#link|Pointer Cast Invalid Null#} panic:2137 are not the same size as pointers. In this code example, if the pointer
2138 did not have the {#syntax#}allowzero{#endsyntax#} attribute, this would be a
2139 {#link|Pointer Cast Invalid Null#} panic:
2138 </p>2140 </p>
2139 {#code_begin|test|allowzero#}2141 {#code_begin|test|allowzero#}
2140const std = @import("std");2142const std = @import("std");