feature. See also
. The project being documented here (as the example) is the Zig library itself.
ubsan_rt.shiftOob
fn shiftOob(
data: *const ShiftOobData,
lhs_handle: ValueHandle,
rhs_handle: ValueHandle,
) callconv(.c) noreturn
File
Code
fn shiftOob(
data: *const ShiftOobData,
lhs_handle: ValueHandle,
rhs_handle: ValueHandle,
) callconv(.c) noreturn {
const lhs: Value = .{ .handle = lhs_handle, .td = data.lhs_type };
const rhs: Value = .{ .handle = rhs_handle, .td = data.rhs_type };
if (rhs.isNegative() or
rhs.getPositiveInteger() >= data.lhs_type.getIntegerSize())
{
if (rhs.isNegative()) {
panic(@returnAddress(), "shift exponent {f} is negative", .{rhs});
} else {
panic(
@returnAddress(),
"shift exponent {f} is too large for {d}-bit type {s}",
.{ rhs, data.lhs_type.getIntegerSize(), data.lhs_type.getName() },
);
}
} else {
if (lhs.isNegative()) {
panic(@returnAddress(), "left shift of negative value {f}", .{lhs});
} else {
panic(
@returnAddress(),
"left shift of {f} by {f} places cannot be represented in type {s}",
.{ lhs, rhs, data.lhs_type.getName() },
);
}
}
}