1#update=initial version
2#file=main.zig
3pub fn main() !u8 {
4 var a: u8 = undefined;
5 a = 255;
6 _ = a + 1;
7 return 1;
8}
9pub const panic = std.debug.FullPanic(myPanic);
10fn myPanic(msg: []const u8, _: ?usize) noreturn {
11 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
12 stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
13 std.process.exit(0);
14}
15const std = @import("std");
16const io = std.Io.Threaded.global_single_threaded.io();
17#expect_stdout="panic message: integer overflow\n"
18
19#update=change the panic handler body
20#file=main.zig
21pub fn main() !u8 {
22 var a: u8 = undefined;
23 a = 255;
24 _ = a + 1;
25 return 1;
26}
27pub const panic = std.debug.FullPanic(myPanic);
28fn myPanic(msg: []const u8, _: ?usize) noreturn {
29 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
30 stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
31 std.process.exit(0);
32}
33const std = @import("std");
34const io = std.Io.Threaded.global_single_threaded.io();
35#expect_stdout="new panic message: integer overflow\n"
36
37#update=change the panic handler function value
38#file=main.zig
39pub fn main() !u8 {
40 var a: u8 = undefined;
41 a = 255;
42 _ = a + 1;
43 return 1;
44}
45pub const panic = std.debug.FullPanic(myPanicNew);
46fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
47 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
48 stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
49 std.process.exit(0);
50}
51const std = @import("std");
52const io = std.Io.Threaded.global_single_threaded.io();
53#expect_stdout="third panic message: integer overflow\n"