zig/test/cases/safety/@intToPtr address zero to non-optional pointer.zig

19 lines
430 B
Zig
Raw Normal View History

const std = @import("std");
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {
_ = stack_trace;
2022-07-16 06:50:32 +08:00
if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
std.process.exit(0);
}
std.process.exit(1);
}
pub fn main() !void {
var zero: usize = 0;
var b = @intToPtr(*i32, zero);
_ = b;
return error.TestFailed;
}
// run
2022-07-16 06:50:32 +08:00
// backend=llvm
// target=native