| 1 | export fn entry2() void { |
| 2 | comptime var slice: []const u16 = &.{ 1, 2, 3 }; |
| 3 | slice.len = undefined; |
| 4 | _ = slice.*; |
| 5 | } |
| 6 | |
| 7 | export fn entry3() void { |
| 8 | comptime var slice: []const u16 = &.{ 1, 2, 3 }; |
| 9 | slice.len = undefined; |
| 10 | _ = &slice.*; |
| 11 | } |
| 12 | |
| 13 | export fn entry4() void { |
| 14 | comptime var slice: []const u8 = "hello"; |
| 15 | slice.len = undefined; |
| 16 | @compileError(slice); |
| 17 | } |
| 18 | |
| 19 | // error |
| 20 | // |
| 21 | // :4:14: error: cannot dereference slice with undefined length |
| 22 | // :10:15: error: cannot dereference slice with undefined length |
| 23 | // :16:19: error: use of slice with undefined length here causes illegal behavior |