feature. See also
. The project being documented here (as the example) is the Zig library itself.
ubsan_rt.typeMismatch
fn typeMismatch(
data: *const TypeMismatchData,
pointer: ?ValueHandle,
) callconv(.c) noreturn
File
Code
fn typeMismatch(
data: *const TypeMismatchData,
pointer: ?ValueHandle,
) callconv(.c) noreturn {
const alignment = @as(usize, 1) << @intCast(data.log_alignment);
const handle: usize = @intFromPtr(pointer);
if (pointer == null) {
panic(
@returnAddress(),
"{s} null pointer of type {s}",
.{ data.kind.getName(), data.td.getName() },
);
} else if (!std.mem.isAligned(handle, alignment)) {
panic(
@returnAddress(),
"{s} misaligned address 0x{x} for type {s}, which requires {d} byte alignment",
.{ data.kind.getName(), handle, data.td.getName(), alignment },
);
} else {
panic(
@returnAddress(),
"{s} address 0x{x} with insufficient space for an object of type {s}",
.{ data.kind.getName(), handle, data.td.getName() },
);
}
}