| ... | ... | @@ -95,67 +95,23 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 95 | 95 | \\} |
| 96 | 96 | ; |
| 97 | 97 | |
| 98 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 98 | cases.addRuntimeSafety("slice with sentinel out of bounds", |
| 99 | 99 | \\const std = @import("std"); |
| 100 | 100 | ++ check_panic_msg ++ |
| 101 | 101 | \\pub fn main() void { |
| 102 | 102 | \\ var buf = [4]u8{'a','b','c',0}; |
| 103 | | \\ const slice = buf[0..4 :0]; |
| 103 | \\ const input: []u8 = &buf; |
| 104 | \\ const slice = input[0..4 :0]; |
| 104 | 105 | \\ _ = slice; |
| 105 | 106 | \\} |
| 106 | 107 | ); |
| 107 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 108 | | \\const std = @import("std"); |
| 109 | | ++ check_panic_msg ++ |
| 110 | | \\pub fn main() void { |
| 111 | | \\ var buf = [4]u8{'a','b','c',0}; |
| 112 | | \\ const slice = buf[0..:0]; |
| 113 | | \\ _ = slice; |
| 114 | | \\} |
| 115 | | ); |
| 116 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 117 | | \\const std = @import("std"); |
| 118 | | ++ check_panic_msg ++ |
| 119 | | \\pub fn main() void { |
| 120 | | \\ var buf_zero = [0]u8{}; |
| 121 | | \\ const slice = buf_zero[0..0 :0]; |
| 122 | | \\ _ = slice; |
| 123 | | \\} |
| 124 | | ); |
| 125 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 108 | cases.addRuntimeSafety("empty slice with sentinel out of bounds", |
| 126 | 109 | \\const std = @import("std"); |
| 127 | 110 | ++ check_panic_msg ++ |
| 128 | 111 | \\pub fn main() void { |
| 129 | 112 | \\ var buf_zero = [0]u8{}; |
| 130 | | \\ const slice = buf_zero[0..:0]; |
| 131 | | \\ _ = slice; |
| 132 | | \\} |
| 133 | | ); |
| 134 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 135 | | \\const std = @import("std"); |
| 136 | | ++ check_panic_msg ++ |
| 137 | | \\pub fn main() void { |
| 138 | | \\ var buf_sentinel = [2:0]u8{'a','b'}; |
| 139 | | \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; |
| 140 | | \\ const slice = buf_sentinel[0..3 :0]; |
| 141 | | \\ _ = slice; |
| 142 | | \\} |
| 143 | | ); |
| 144 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 145 | | \\const std = @import("std"); |
| 146 | | ++ check_panic_msg ++ |
| 147 | | \\pub fn main() void { |
| 148 | | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 149 | | \\ const slice = buf_slice[0..3 :0]; |
| 150 | | \\ _ = slice; |
| 151 | | \\} |
| 152 | | ); |
| 153 | | cases.addRuntimeSafety("slicing operator with sentinel", |
| 154 | | \\const std = @import("std"); |
| 155 | | ++ check_panic_msg ++ |
| 156 | | \\pub fn main() void { |
| 157 | | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 158 | | \\ const slice = buf_slice[0.. :0]; |
| 113 | \\ const input: []u8 = &buf_zero; |
| 114 | \\ const slice = input[0..0 :0]; |
| 159 | 115 | \\ _ = slice; |
| 160 | 116 | \\} |
| 161 | 117 | ); |