| ... | @@ -89,7 +89,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -89,7 +89,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 89 | \\const std = @import("std"); | 89 | \\const std = @import("std"); |
| 90 | \\const V = @import("std").meta.Vector; | 90 | \\const V = @import("std").meta.Vector; |
| 91 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { | 91 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
| 92 | \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { | 92 | \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { |
| 93 | \\ std.process.exit(126); // good | 93 | \\ std.process.exit(126); // good |
| 94 | \\ } | 94 | \\ } |
| 95 | \\ std.process.exit(0); // test failed | 95 | \\ std.process.exit(0); // test failed |
| ... | @@ -100,6 +100,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -100,6 +100,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 100 | \\} | 100 | \\} |
| 101 | ); | 101 | ); |
| 102 | | 102 | |
| | 103 | cases.addRuntimeSafety("signed-unsigned vector cast", |
| | 104 | \\const std = @import("std"); |
| | 105 | \\const V = @import("std").meta.Vector; |
| | 106 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
| | 107 | \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { |
| | 108 | \\ std.process.exit(126); // good |
| | 109 | \\ } |
| | 110 | \\ std.process.exit(0); // test failed |
| | 111 | \\} |
| | 112 | \\pub fn main() void { |
| | 113 | \\ var x = @splat(4, @as(i32, -2147483647)); |
| | 114 | \\ var y = @intCast(V(4, u32), x); |
| | 115 | \\} |
| | 116 | ); |
| | 117 | |
| 103 | cases.addRuntimeSafety("shift left by huge amount", | 118 | cases.addRuntimeSafety("shift left by huge amount", |
| 104 | \\const std = @import("std"); | 119 | \\const std = @import("std"); |
| 105 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { | 120 | \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |