Files
zig/test/cases/compile_errors/pointer_in_bitpack.zig
2026-03-10 10:26:14 +00:00

23 lines
564 B
Zig

const S = packed struct {
ptr: *u32,
};
export fn foo() void {
_ = @as(S, undefined);
}
const U = packed union {
ptr: *u32,
};
export fn bar() void {
_ = @as(U, undefined);
}
// error
//
// :2:10: error: packed structs cannot contain fields of type '*u32'
// :2:10: note: pointers cannot be directly bitpacked
// :2:10: note: consider using 'usize' and '@intFromPtr'
// :9:10: error: packed unions cannot contain fields of type '*u32'
// :9:10: note: pointers cannot be directly bitpacked
// :9:10: note: consider using 'usize' and '@intFromPtr'