2022-05-13 15:00:20 +08:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {
|
|
|
|
_ = stack_trace;
|
2022-08-05 21:49:06 +08:00
|
|
|
if (std.mem.eql(u8, message, "switch on corrupt value")) {
|
2022-05-13 15:00:20 +08:00
|
|
|
std.process.exit(0);
|
|
|
|
}
|
|
|
|
std.process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const U = union(enum(u32)) {
|
|
|
|
X: u8,
|
2022-08-05 21:49:06 +08:00
|
|
|
Y: i8,
|
2022-05-13 15:00:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
pub fn main() !void {
|
|
|
|
var u: U = undefined;
|
|
|
|
@memset(@ptrCast([*]u8, &u), 0x55, @sizeOf(U));
|
|
|
|
switch (u) {
|
2022-08-05 21:49:06 +08:00
|
|
|
.X, .Y => @breakpoint(),
|
2022-05-13 15:00:20 +08:00
|
|
|
}
|
|
|
|
return error.TestFailed;
|
|
|
|
}
|
|
|
|
|
|
|
|
// run
|
2022-08-05 21:49:06 +08:00
|
|
|
// backend=llvm
|
2022-05-14 08:58:32 +08:00
|
|
|
// target=native
|