I have two packed structs that look something like this:
pub const Inner= packed struct {
bits: u3,
more_bits: u6,
};
pub const Outer = packed struct {
padding: u5,
inner: Inner,
};
Then when assigning a inner value to outer, the compiler will miss-align the assignment. For example the code:
var r: *volatile Outer = SOME_VALID_ADDRESS;
fn t(inner: Inner) void {
r.inner = inner;
}
Will result in the first five bits of inner being assigned to padding.
zig version 0.9.0-dev.804+4c9d41730
Arch: Thumb
Model: Arm7tdmi
OS: Freestanding
I have two packed structs that look something like this:
Then when assigning a inner value to outer, the compiler will miss-align the assignment. For example the code:
Will result in the first five bits of inner being assigned to padding.
zig version 0.9.0-dev.804+4c9d41730
Arch: Thumb
Model: Arm7tdmi
OS: Freestanding