Open andrewrk opened 5 years ago
Extracted from https://github.com/ziglang/zig/issues/1059#issuecomment-462101897
These apply to unknown length pointers and C pointers.
Should also check that the resulting pointer if non-allowzero
doesn't result in zero like it can currently:
const std = @import("std");
pub fn main() void {
const x: [*]u8 = @ptrFromInt(1);
const a: [*]u8 = x - 1;
std.debug.print("address: {*}\n",.{a});
}
address: u8@0
There should be a test in test/runtime_safety.zig to make sure that unknown length pointer arithmetic does not wrap past the end of the address space.