| ... | @@ -13,7 +13,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -13,7 +13,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 13 | | 13 | |
| 14 | cases.addRuntimeSafety("slicing operator with sentinel", | 14 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 15 | \\const std = @import("std"); | 15 | \\const std = @import("std"); |
| 16 | ++ check_panic_msg ++ | 16 | ++ check_panic_msg ++ |
| 17 | \\pub fn main() void { | 17 | \\pub fn main() void { |
| 18 | \\ var buf = [4]u8{'a','b','c',0}; | 18 | \\ var buf = [4]u8{'a','b','c',0}; |
| 19 | \\ const slice = buf[0..4 :0]; | 19 | \\ const slice = buf[0..4 :0]; |
| ... | @@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 21 | ); | 21 | ); |
| 22 | cases.addRuntimeSafety("slicing operator with sentinel", | 22 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 23 | \\const std = @import("std"); | 23 | \\const std = @import("std"); |
| 24 | ++ check_panic_msg ++ | 24 | ++ check_panic_msg ++ |
| 25 | \\pub fn main() void { | 25 | \\pub fn main() void { |
| 26 | \\ var buf = [4]u8{'a','b','c',0}; | 26 | \\ var buf = [4]u8{'a','b','c',0}; |
| 27 | \\ const slice = buf[0..:0]; | 27 | \\ const slice = buf[0..:0]; |
| ... | @@ -29,7 +29,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -29,7 +29,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 29 | ); | 29 | ); |
| 30 | cases.addRuntimeSafety("slicing operator with sentinel", | 30 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 31 | \\const std = @import("std"); | 31 | \\const std = @import("std"); |
| 32 | ++ check_panic_msg ++ | 32 | ++ check_panic_msg ++ |
| 33 | \\pub fn main() void { | 33 | \\pub fn main() void { |
| 34 | \\ var buf_zero = [0]u8{}; | 34 | \\ var buf_zero = [0]u8{}; |
| 35 | \\ const slice = buf_zero[0..0 :0]; | 35 | \\ const slice = buf_zero[0..0 :0]; |
| ... | @@ -37,7 +37,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -37,7 +37,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 37 | ); | 37 | ); |
| 38 | cases.addRuntimeSafety("slicing operator with sentinel", | 38 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 39 | \\const std = @import("std"); | 39 | \\const std = @import("std"); |
| 40 | ++ check_panic_msg ++ | 40 | ++ check_panic_msg ++ |
| 41 | \\pub fn main() void { | 41 | \\pub fn main() void { |
| 42 | \\ var buf_zero = [0]u8{}; | 42 | \\ var buf_zero = [0]u8{}; |
| 43 | \\ const slice = buf_zero[0..:0]; | 43 | \\ const slice = buf_zero[0..:0]; |
| ... | @@ -45,7 +45,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -45,7 +45,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 45 | ); | 45 | ); |
| 46 | cases.addRuntimeSafety("slicing operator with sentinel", | 46 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 47 | \\const std = @import("std"); | 47 | \\const std = @import("std"); |
| 48 | ++ check_panic_msg ++ | 48 | ++ check_panic_msg ++ |
| 49 | \\pub fn main() void { | 49 | \\pub fn main() void { |
| 50 | \\ var buf_sentinel = [2:0]u8{'a','b'}; | 50 | \\ var buf_sentinel = [2:0]u8{'a','b'}; |
| 51 | \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; | 51 | \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; |
| ... | @@ -54,7 +54,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -54,7 +54,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 54 | ); | 54 | ); |
| 55 | cases.addRuntimeSafety("slicing operator with sentinel", | 55 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 56 | \\const std = @import("std"); | 56 | \\const std = @import("std"); |
| 57 | ++ check_panic_msg ++ | 57 | ++ check_panic_msg ++ |
| 58 | \\pub fn main() void { | 58 | \\pub fn main() void { |
| 59 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; | 59 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 60 | \\ const slice = buf_slice[0..3 :0]; | 60 | \\ const slice = buf_slice[0..3 :0]; |
| ... | @@ -62,7 +62,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -62,7 +62,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 62 | ); | 62 | ); |
| 63 | cases.addRuntimeSafety("slicing operator with sentinel", | 63 | cases.addRuntimeSafety("slicing operator with sentinel", |
| 64 | \\const std = @import("std"); | 64 | \\const std = @import("std"); |
| 65 | ++ check_panic_msg ++ | 65 | ++ check_panic_msg ++ |
| 66 | \\pub fn main() void { | 66 | \\pub fn main() void { |
| 67 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; | 67 | \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; |
| 68 | \\ const slice = buf_slice[0.. :0]; | 68 | \\ const slice = buf_slice[0.. :0]; |
| ... | @@ -354,7 +354,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -354,7 +354,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 354 | \\} | 354 | \\} |
| 355 | ); | 355 | ); |
| 356 | | 356 | |
| 357 | cases.addRuntimeSafety("@ptrToInt address zero to non-optional pointer", | 357 | cases.addRuntimeSafety("@intToPtr address zero to non-optional pointer", |
| 358 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { | 358 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
| 359 | \\ @import("std").os.exit(126); | 359 | \\ @import("std").os.exit(126); |
| 360 | \\} | 360 | \\} |
| ... | @@ -364,6 +364,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -364,6 +364,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 364 | \\} | 364 | \\} |
| 365 | ); | 365 | ); |
| 366 | | 366 | |
| | 367 | cases.addRuntimeSafety("@intToPtr address zero to non-optional byte-aligned pointer", |
| | 368 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
| | 369 | \\ @import("std").os.exit(126); |
| | 370 | \\} |
| | 371 | \\pub fn main() void { |
| | 372 | \\ var zero: usize = 0; |
| | 373 | \\ var b = @intToPtr(*u8, zero); |
| | 374 | \\} |
| | 375 | ); |
| | 376 | |
| 367 | cases.addRuntimeSafety("pointer casting null to non-optional pointer", | 377 | cases.addRuntimeSafety("pointer casting null to non-optional pointer", |
| 368 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { | 378 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
| 369 | \\ @import("std").os.exit(126); | 379 | \\ @import("std").os.exit(126); |