authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-15 00:43:48+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-09-20 19:05:00-07:00
log694fab484805088030fa36efe3e6b6e7ee385852
tree451290910b16372dfdad4336efbc0124248582d7
parent8f2e82dbf63aedc64af5c701c4798e9fbd51de72

std: add return address parameter to panic fn


91 files changed, 114 insertions(+), 101 deletions(-)

lib/c.zig+1-1
...@@ -58,7 +58,7 @@ comptime {...@@ -58,7 +58,7 @@ comptime {
5858
59// Avoid dragging in the runtime safety mechanisms into this .o file,59// Avoid dragging in the runtime safety mechanisms into this .o file,
60// unless we're trying to test this file.60// unless we're trying to test this file.
61pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {61pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
62 @setCold(true);62 @setCold(true);
63 _ = error_return_trace;63 _ = error_return_trace;
64 if (builtin.is_test) {64 if (builtin.is_test) {
lib/compiler_rt/common.zig+1-1
...@@ -60,7 +60,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();...@@ -60,7 +60,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
6060
61// Avoid dragging in the runtime safety mechanisms into this .o file,61// Avoid dragging in the runtime safety mechanisms into this .o file,
62// unless we're trying to test compiler-rt.62// unless we're trying to test compiler-rt.
63pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {63pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
64 _ = error_return_trace;64 _ = error_return_trace;
65 if (builtin.is_test) {65 if (builtin.is_test) {
66 @setCold(true);66 @setCold(true);
lib/ssp.zig+1-1
...@@ -20,7 +20,7 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call...@@ -20,7 +20,7 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
20extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;20extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;
2121
22// Avoid dragging in the runtime safety mechanisms into this .o file.22// Avoid dragging in the runtime safety mechanisms into this .o file.
23pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {23pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
24 _ = msg;24 _ = msg;
25 _ = error_return_trace;25 _ = error_return_trace;
26 @setCold(true);26 @setCold(true);
lib/std/builtin.zig+6-6
...@@ -748,7 +748,7 @@ const testFnProto = switch (builtin.zig_backend) {...@@ -748,7 +748,7 @@ const testFnProto = switch (builtin.zig_backend) {
748748
749/// This function type is used by the Zig language code generation and749/// This function type is used by the Zig language code generation and
750/// therefore must be kept in sync with the compiler implementation.750/// therefore must be kept in sync with the compiler implementation.
751pub const PanicFn = fn ([]const u8, ?*StackTrace) noreturn;751pub const PanicFn = fn ([]const u8, ?*StackTrace, ?usize) noreturn;
752752
753/// This function is used by the Zig language code generation and753/// This function is used by the Zig language code generation and
754/// therefore must be kept in sync with the compiler implementation.754/// therefore must be kept in sync with the compiler implementation.
...@@ -761,7 +761,7 @@ else...@@ -761,7 +761,7 @@ else
761761
762/// This function is used by the Zig language code generation and762/// This function is used by the Zig language code generation and
763/// therefore must be kept in sync with the compiler implementation.763/// therefore must be kept in sync with the compiler implementation.
764pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn {764pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn {
765 @setCold(true);765 @setCold(true);
766766
767 // Until self-hosted catches up with stage1 language features, we have a simpler767 // Until self-hosted catches up with stage1 language features, we have a simpler
...@@ -839,7 +839,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn...@@ -839,7 +839,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
839 std.os.abort();839 std.os.abort();
840 },840 },
841 else => {841 else => {
842 const first_trace_addr = @returnAddress();842 const first_trace_addr = ret_addr orelse @returnAddress();
843 std.debug.panicImpl(error_return_trace, first_trace_addr, msg);843 std.debug.panicImpl(error_return_trace, first_trace_addr, msg);
844 },844 },
845 }845 }
...@@ -853,17 +853,17 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void...@@ -853,17 +853,17 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void
853853
854pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {854pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {
855 @setCold(true);855 @setCold(true);
856 std.debug.panic("sentinel mismatch: expected {any}, found {any}", .{ expected, actual });856 std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
857}857}
858858
859pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {859pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {
860 @setCold(true);860 @setCold(true);
861 std.debug.panicExtra(st, "attempt to unwrap error: {s}", .{@errorName(err)});861 std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
862}862}
863863
864pub fn panicOutOfBounds(index: usize, len: usize) noreturn {864pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
865 @setCold(true);865 @setCold(true);
866 std.debug.panic("index out of bounds: index {d}, len {d}", .{ index, len });866 std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
867}867}
868868
869pub noinline fn returnError(st: *StackTrace) void {869pub noinline fn returnError(st: *StackTrace) void {
lib/std/debug.zig+3-2
...@@ -284,13 +284,14 @@ pub fn assert(ok: bool) void {...@@ -284,13 +284,14 @@ pub fn assert(ok: bool) void {
284pub fn panic(comptime format: []const u8, args: anytype) noreturn {284pub fn panic(comptime format: []const u8, args: anytype) noreturn {
285 @setCold(true);285 @setCold(true);
286286
287 panicExtra(null, format, args);287 panicExtra(null, null, format, args);
288}288}
289289
290/// `panicExtra` is useful when you want to print out an `@errorReturnTrace`290/// `panicExtra` is useful when you want to print out an `@errorReturnTrace`
291/// and also print out some values.291/// and also print out some values.
292pub fn panicExtra(292pub fn panicExtra(
293 trace: ?*std.builtin.StackTrace,293 trace: ?*std.builtin.StackTrace,
294 ret_addr: ?usize,
294 comptime format: []const u8,295 comptime format: []const u8,
295 args: anytype,296 args: anytype,
296) noreturn {297) noreturn {
...@@ -308,7 +309,7 @@ pub fn panicExtra(...@@ -308,7 +309,7 @@ pub fn panicExtra(
308 break :blk &buf;309 break :blk &buf;
309 },310 },
310 };311 };
311 std.builtin.panic(msg, trace);312 std.builtin.panic(msg, trace, ret_addr);
312}313}
313314
314/// Non-zero whenever the program triggered a panic.315/// Non-zero whenever the program triggered a panic.
src/Sema.zig+3-3
...@@ -1955,7 +1955,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {...@@ -1955,7 +1955,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {
1955 err_msg.src_loc.file_scope.sub_file_path,1955 err_msg.src_loc.file_scope.sub_file_path,
1956 err_msg.src_loc.lazy,1956 err_msg.src_loc.lazy,
1957 });1957 });
1958 crash_report.compilerPanic("unexpected compile error occurred", null);1958 crash_report.compilerPanic("unexpected compile error occurred", null, null);
1959 }1959 }
19601960
1961 const mod = sema.mod;1961 const mod = sema.mod;
...@@ -10468,7 +10468,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op...@@ -10468,7 +10468,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op
1046810468
10469 const panic_fn = try sema.getBuiltin(block, src, "panic");10469 const panic_fn = try sema.getBuiltin(block, src, "panic");
10470 const err_return_trace = try sema.getErrorReturnTrace(block, src);10470 const err_return_trace = try sema.getErrorReturnTrace(block, src);
10471 const args: [2]Air.Inst.Ref = .{ msg_inst, err_return_trace };10471 const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value };
10472 _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null);10472 _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null);
10473 return true;10473 return true;
10474 },10474 },
...@@ -21139,7 +21139,7 @@ fn panicWithMsg(...@@ -21139,7 +21139,7 @@ fn panicWithMsg(
21139 try Type.optional(arena, ptr_stack_trace_ty),21139 try Type.optional(arena, ptr_stack_trace_ty),
21140 Value.@"null",21140 Value.@"null",
21141 );21141 );
21142 const args: [2]Air.Inst.Ref = .{ msg_inst, null_stack_trace };21142 const args: [3]Air.Inst.Ref = .{ msg_inst, null_stack_trace, .null_value };
21143 _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null);21143 _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null);
21144 return always_noreturn;21144 return always_noreturn;
21145}21145}
src/crash_report.zig+2-2
...@@ -155,10 +155,10 @@ fn writeFullyQualifiedDeclWithFile(mod: *Module, decl: *Decl, stream: anytype) !...@@ -155,10 +155,10 @@ fn writeFullyQualifiedDeclWithFile(mod: *Module, decl: *Decl, stream: anytype) !
155 try decl.renderFullyQualifiedDebugName(mod, stream);155 try decl.renderFullyQualifiedDebugName(mod, stream);
156}156}
157157
158pub fn compilerPanic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {158pub fn compilerPanic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, maybe_ret_addr: ?usize) noreturn {
159 PanicSwitch.preDispatch();159 PanicSwitch.preDispatch();
160 @setCold(true);160 @setCold(true);
161 const ret_addr = @returnAddress();161 const ret_addr = maybe_ret_addr orelse @returnAddress();
162 const stack_ctx: StackContext = .{ .current = .{ .ret_addr = ret_addr } };162 const stack_ctx: StackContext = .{ .current = .{ .ret_addr = ret_addr } };
163 PanicSwitch.dispatch(error_return_trace, stack_ctx, msg);163 PanicSwitch.dispatch(error_return_trace, stack_ctx, msg);
164}164}
src/stage1/codegen.cpp+13-1
...@@ -1086,11 +1086,23 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace...@@ -1086,11 +1086,23 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace
1086 if (stack_trace_arg == nullptr) {1086 if (stack_trace_arg == nullptr) {
1087 stack_trace_arg = LLVMConstNull(get_llvm_type(g, ptr_to_stack_trace_type(g)));1087 stack_trace_arg = LLVMConstNull(get_llvm_type(g, ptr_to_stack_trace_type(g)));
1088 }1088 }
1089 LLVMValueRef null_ret_alloc;
1090 {
1091 ZigValue null_val = {};
1092 null_val.special = ConstValSpecialStatic;
1093 null_val.data.x_optional = nullptr;
1094 null_val.type = get_optional_type2(g, g->builtin_types.entry_usize);
1095 LLVMValueRef null_ret_val = gen_const_val(g, &null_val, "");
1096 null_ret_alloc = build_alloca(g, null_val.type, "ret_addr", 0);
1097 LLVMBuildStore(g->builder, null_ret_val, null_ret_alloc);
1098 }
1099
1089 LLVMValueRef args[] = {1100 LLVMValueRef args[] = {
1090 msg_arg,1101 msg_arg,
1091 stack_trace_arg,1102 stack_trace_arg,
1103 null_ret_alloc,
1092 };1104 };
1093 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, args, 2, llvm_cc, ZigLLVM_CallAttrAuto, "");1105 ZigLLVMBuildCall(g->builder, LLVMGlobalGetValueType(fn_val), fn_val, args, 3, llvm_cc, ZigLLVM_CallAttrAuto, "");
1094 if (!stack_trace_is_llvm_alloca) {1106 if (!stack_trace_is_llvm_alloca) {
1095 // The stack trace argument is not in the stack of the caller, so1107 // The stack trace argument is not in the stack of the caller, so
1096 // we'd like to set tail call here, but because slices (the type of msg_arg) are1108 // we'd like to set tail call here, but because slices (the type of msg_arg) are
test/cases/compile_errors/stage1/obj/wrong_panic_signature_generic_function.zig+2-2
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1pub fn panic(comptime msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {1pub fn panic(comptime msg: []const u8, error_return_trace: ?*builtin.StackTrace, _: ?usize) noreturn {
2 _ = msg; _ = error_return_trace;2 _ = msg; _ = error_return_trace;
3 while (true) {}3 while (true) {}
4}4}
...@@ -8,5 +8,5 @@ const builtin = @import("std").builtin;...@@ -8,5 +8,5 @@ const builtin = @import("std").builtin;
8// backend=stage18// backend=stage1
9// target=native9// target=native
10//10//
11// error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,anytype) anytype'11// error: expected type 'fn([]const u8, ?*std.builtin.StackTrace, ?usize) noreturn', found 'fn([]const u8,anytype,anytype) anytype'
12// note: only one of the functions is generic12// note: only one of the functions is generic
test/cases/compile_errors/stage1/obj/wrong_panic_signature_runtime_function.zig+1-1
...@@ -7,4 +7,4 @@ pub fn panic() void {}...@@ -7,4 +7,4 @@ pub fn panic() void {}
7// backend=stage17// backend=stage1
8// target=native8// target=native
9//9//
10// error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn() void'10// error: expected type 'fn([]const u8, ?*std.builtin.StackTrace, ?usize) noreturn', found 'fn() void'
test/cases/safety/@alignCast misaligned.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "incorrect alignment")) {5 if (std.mem.eql(u8, message, "incorrect alignment")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@asyncCall with too small a frame.zig +1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {4pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
5 _ = message;5 _ = message;
6 _ = stack_trace;6 _ = stack_trace;
7 std.process.exit(0);7 std.process.exit(0);
test/cases/safety/@errSetCast error not present in destination.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid error code")) {5 if (std.mem.eql(u8, message, "invalid error code")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@floatToInt cannot fit - negative out of range.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@floatToInt cannot fit - positive out of range.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@intCast to u0.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@intToEnum - no matching tag value.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid enum value")) {5 if (std.mem.eql(u8, message, "invalid enum value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@intToPtr address zero to non-optional pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@tagName on corrupted enum value.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid enum value")) {5 if (std.mem.eql(u8, message, "invalid enum value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/@tagName on corrupted union value.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid enum value")) {5 if (std.mem.eql(u8, message, "invalid enum value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/array slice sentinel mismatch non-scalar.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected tmp.main.S{ .a = 1 }, found tmp.main.S{ .a = 2 }")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected tmp.main.S{ .a = 1 }, found tmp.main.S{ .a = 2 }")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/array slice sentinel mismatch vector.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected { 0, 0 }, found { 4, 4 }")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected { 0, 0 }, found { 4, 4 }")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/array slice sentinel mismatch.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/awaiting twice.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/bad union field access.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "access of inactive union field")) {5 if (std.mem.eql(u8, message, "access of inactive union field")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/calling panic.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "oh no")) {5 if (std.mem.eql(u8, message, "oh no")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/cast []u8 to bigger slice of wrong size.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "exact division produced remainder")) {5 if (std.mem.eql(u8, message, "exact division produced remainder")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/cast integer to global error and no code matches.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid error code")) {5 if (std.mem.eql(u8, message, "invalid error code")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/empty slice with sentinel out of bounds.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "index out of bounds: index 1, len 0")) {5 if (std.mem.eql(u8, message, "index out of bounds: index 1, len 0")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/error return trace across suspend points.zig +1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const std = @import("std");1const std = @import("std");
22
33
4pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {4pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
5 _ = message;5 _ = message;
6 _ = stack_trace;6 _ = stack_trace;
7 std.process.exit(0);7 std.process.exit(0);
test/cases/safety/exact division failure - vectors.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "exact division produced remainder")) {5 if (std.mem.eql(u8, message, "exact division produced remainder")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/exact division failure.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "exact division produced remainder")) {5 if (std.mem.eql(u8, message, "exact division produced remainder")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/intToPtr with misaligned address.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "incorrect alignment")) {5 if (std.mem.eql(u8, message, "incorrect alignment")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer addition overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer division by zero - vectors.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "division by zero")) {5 if (std.mem.eql(u8, message, "division by zero")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer division by zero.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "division by zero")) {5 if (std.mem.eql(u8, message, "division by zero")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer multiplication overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer negation overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/integer subtraction overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/invalid resume of async function.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/modrem by zero.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "division by zero")) {5 if (std.mem.eql(u8, message, "division by zero")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/modulus by zero.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "division by zero")) {5 if (std.mem.eql(u8, message, "division by zero")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/nosuspend function call, callee suspends.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/optional unwrap operator on C pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to use null value")) {5 if (std.mem.eql(u8, message, "attempt to use null value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/optional unwrap operator on null pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to use null value")) {5 if (std.mem.eql(u8, message, "attempt to use null value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/out of bounds slice access.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "index out of bounds: index 4, len 4")) {5 if (std.mem.eql(u8, message, "index out of bounds: index 4, len 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/pointer casting null to non-optional pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/pointer slice sentinel mismatch.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/remainder division by zero.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "division by zero")) {5 if (std.mem.eql(u8, message, "division by zero")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/resuming a function which is awaiting a call.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/resuming a function which is awaiting a frame.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/resuming a non-suspended function which never been suspended.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = message;4 _ = message;
5 _ = stack_trace;5 _ = stack_trace;
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/shift left by huge amount.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "shift amount is greater than the type size")) {5 if (std.mem.eql(u8, message, "shift amount is greater than the type size")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/shift right by huge amount.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "shift amount is greater than the type size")) {5 if (std.mem.eql(u8, message, "shift amount is greater than the type size")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed integer division overflow - vectors.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed integer division overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed integer not fitting in cast to unsigned integer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed shift left overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "left shift overflowed bits")) {5 if (std.mem.eql(u8, message, "left shift overflowed bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed shift right overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "right shift overflowed bits")) {5 if (std.mem.eql(u8, message, "right shift overflowed bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/signed-unsigned vector cast.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {5 if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slice sentinel mismatch - floats.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 1.20000004e+00, found 4.0e+00")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 1.20000004e+00, found 4.0e+00")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slice sentinel mismatch - optional pointers.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected null, found i32@10")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected null, found i32@10")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slice slice sentinel mismatch.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {5 if (std.mem.eql(u8, message, "sentinel mismatch: expected 0, found 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slice with sentinel out of bounds - runtime len.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) {5 if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slice with sentinel out of bounds.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) {5 if (std.mem.eql(u8, message, "index out of bounds: index 5, len 4")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slicing null C pointer - runtime len.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to use null value")) {5 if (std.mem.eql(u8, message, "attempt to use null value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/slicing null C pointer.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to use null value")) {5 if (std.mem.eql(u8, message, "attempt to use null value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/switch on corrupted enum value.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "switch on corrupt value")) {5 if (std.mem.eql(u8, message, "switch on corrupt value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/switch on corrupted union value.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "switch on corrupt value")) {5 if (std.mem.eql(u8, message, "switch on corrupt value")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/truncating vector cast.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unreachable.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "reached unreachable code")) {5 if (std.mem.eql(u8, message, "reached unreachable code")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unsigned shift left overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "left shift overflowed bits")) {5 if (std.mem.eql(u8, message, "left shift overflowed bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unsigned shift right overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "right shift overflowed bits")) {5 if (std.mem.eql(u8, message, "right shift overflowed bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unsigned-signed vector cast.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unwrap error switch.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) {5 if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/unwrap error.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) {5 if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/value does not fit in shortening cast - u0.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/value does not fit in shortening cast.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {5 if (std.mem.eql(u8, message, "integer cast truncated bits")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/vector integer addition overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/vector integer multiplication overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/vector integer negation overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/vector integer subtraction overflow.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer overflow")) {5 if (std.mem.eql(u8, message, "integer overflow")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cases/safety/zero casted to error.zig +1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid error code")) {5 if (std.mem.eql(u8, message, "invalid error code")) {
6 std.process.exit(0);6 std.process.exit(0);
test/cli.zig+1-1
...@@ -120,7 +120,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {...@@ -120,7 +120,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
120 \\ return num * num;120 \\ return num * num;
121 \\}121 \\}
122 \\extern fn zig_panic() noreturn;122 \\extern fn zig_panic() noreturn;
123 \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn {123 \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace, _: ?usize) noreturn {
124 \\ _ = msg;124 \\ _ = msg;
125 \\ _ = error_return_trace;125 \\ _ = error_return_trace;
126 \\ zig_panic();126 \\ zig_panic();
test/standalone/issue_339/test.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const StackTrace = @import("std").builtin.StackTrace;1const StackTrace = @import("std").builtin.StackTrace;
2pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn {2pub fn panic(msg: []const u8, stack_trace: ?*StackTrace, _: ?usize) noreturn {
3 _ = msg;3 _ = msg;
4 _ = stack_trace;4 _ = stack_trace;
5 @breakpoint();5 @breakpoint();
test/standalone/issue_8550/main.zig+1-1
...@@ -4,7 +4,7 @@ export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn {...@@ -4,7 +4,7 @@ export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn {
4 _ = atags;4 _ = atags;
5 unreachable; // never gets run so it doesn't matter5 unreachable; // never gets run so it doesn't matter
6}6}
7pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn {7pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace, _: ?usize) noreturn {
8 _ = msg;8 _ = msg;
9 _ = error_return_trace;9 _ = error_return_trace;
10 while (true) {}10 while (true) {}