| ... | @@ -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 the | 2134 | 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, use | 2135 | 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 the | 2136 | {#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#} |
| 2140 | const std = @import("std"); | 2142 | const std = @import("std"); |