diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-11-07 10:37:44 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-11-09 18:24:48 -0500 |
| commit | e00356d6b143feb0de82572ad8aa4f5d11dfba91 (patch) | |
| tree | cbc4a783497d81b75fadeb967cbaafd5fc2ccae5 /test/runtime_safety.zig | |
| parent | 427a212e3865ba73bc6df63c71ce2849ae2de583 (diff) | |
| download | zig-e00356d6b143feb0de82572ad8aa4f5d11dfba91.tar.gz zig-e00356d6b143feb0de82572ad8aa4f5d11dfba91.zip | |
stage1: Print correct error message for vector @intCast
Diffstat (limited to 'test/runtime_safety.zig')
| -rw-r--r-- | test/runtime_safety.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index a0b4a555a5..f4bcfa6f9f 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -89,7 +89,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); \\const V = @import("std").meta.Vector; \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { - \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { + \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { \\ std.process.exit(126); // good \\ } \\ std.process.exit(0); // test failed @@ -100,6 +100,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\} ); + cases.addRuntimeSafety("signed-unsigned vector cast", + \\const std = @import("std"); + \\const V = @import("std").meta.Vector; + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { + \\ std.process.exit(126); // good + \\ } + \\ std.process.exit(0); // test failed + \\} + \\pub fn main() void { + \\ var x = @splat(4, @as(i32, -2147483647)); + \\ var y = @intCast(V(4, u32), x); + \\} + ); + cases.addRuntimeSafety("shift left by huge amount", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { |
