Closed
Description
Possibly related to #788.
I have a piece of code that processes smaller sequential slices of a larger slice. Rather than getting a slice of length zero at the end, I get a segmentation fault.
const std = @import("std");
const CHUNK_LEN = 2;
fn slice_to_zero(input: []const u8) void {
while (input.len > 0) {
const take = std.math.min(input.len, CHUNK_LEN);
_ = input[0..take]; // Imagine this slice chunk is used for something
input = input[take..];
}
}
test "slicing down to zero length" {
slice_to_zero("");
slice_to_zero("foo");
}