Currently, this code segfaults on my x86-64 machine:
const std = @import("std");
pub fn main() !void {
var page = try std.heap.page_allocator.alloc(u8, std.mem.page_size);
defer std.heap.page_allocator.free(page);
const ptr = @as(*align(1) u24, @ptrCast(page.ptr + std.mem.page_size - 3));
std.debug.print("{x}", .{ptr.*});
}
Even though all the bytes relevant to the u24 are contained within the page, this still breaks, because @sizeOf(u24) == 4, and the assembly reads a dword, crossing the page boundary, since there is of course no such thing as a 1.5word.
This seems to be the cause of #stdlib-devel message.
Is this intended behavior?