the.bay.news

Field Pointer Alignment

Ziggit
Field Pointer Alignment
Consider the code: test { const MyStruct = struct { x: u32 }; var my_struct: MyStruct align(8) = .{ .x = 5 }; const ptr: *align(8) u32 = &my_struct.x; _ = ptr; } Currently, it fails, with this compiler error: repro.zig:4:32: error: expected type '*align(8) u32', found '*u32' const ptr: *align(8) u32 = &my_struct.x; ^~~~~~~~~~~~ repro.zig:4:32: note: pointer alignment '4' cannot cast into pointer alignment '8' While, if x has an offset of zer...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.