diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-03-25 09:09:32 -0700 |
|---|---|---|
| committer | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-03-27 09:20:35 -0700 |
| commit | 01698528d1dff627b7e057651b137c20df7c7231 (patch) | |
| tree | 1f9238b1eaaf69ddfb7b8750d590b1f5fb9d54a9 /test/compile_errors | |
| parent | d15bbebe2e6b8fcbfcd730a6c0d1be621b27045d (diff) | |
| download | zig-01698528d1dff627b7e057651b137c20df7c7231.tar.gz zig-01698528d1dff627b7e057651b137c20df7c7231.zip | |
stage2: safety checks for slicing a null C pointer
Diffstat (limited to 'test/compile_errors')
| -rw-r--r-- | test/compile_errors/stage2/slice_of_null_pointer.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/compile_errors/stage2/slice_of_null_pointer.zig b/test/compile_errors/stage2/slice_of_null_pointer.zig new file mode 100644 index 0000000000..1e3f0d6aee --- /dev/null +++ b/test/compile_errors/stage2/slice_of_null_pointer.zig @@ -0,0 +1,10 @@ +comptime { + var x: [*c]u8 = null; + var runtime_len: usize = 0; + var y = x[0..runtime_len]; + _ = y; +} + +// slice of null C pointer +// +// :4:14: error: slice of null pointer |
