Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overaligned pointer to packed struct always gives align(1) for fields #1994

andrewrk opened this Issue Feb 22, 2019 · 0 comments


None yet
1 participant
Copy link

andrewrk commented Feb 22, 2019

This test fails:

const S = packed struct {
    a: u32,
    b: u32,
test "overaligned pointer to packed struct" {
    var foo: S align(4) = undefined;
    const ptr: *align(4) S = &foo;
    const ptr_to_b: *u32 = &ptr.b;

But Zig should know that if you have a pointer aligned to 4 bytes and then you add 4 bytes to it, it will still be 4 byte aligned.

Related: #1528

@andrewrk andrewrk added the bug label Feb 22, 2019

@andrewrk andrewrk added this to the 0.4.0 milestone Feb 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.