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

Open
andrewrk opened this issue Feb 22, 2019 · 0 comments
Open

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

andrewrk opened this issue Feb 22, 2019 · 0 comments
Labels
Milestone

Comments

@andrewrk
Copy link
Member

@andrewrk 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
@andrewrk andrewrk removed this from the 0.4.0 milestone Apr 8, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone Apr 8, 2019
@andrewrk andrewrk removed this from the 0.5.0 milestone Sep 24, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Sep 24, 2019
@andrewrk andrewrk removed this from the 0.6.0 milestone Mar 12, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Mar 12, 2020
@andrewrk andrewrk removed this from the 0.7.0 milestone Oct 30, 2020
@andrewrk andrewrk added this to the 0.8.0 milestone Oct 30, 2020
@andrewrk andrewrk removed this from the 0.8.0 milestone Nov 6, 2020
@andrewrk andrewrk added this to the 0.9.0 milestone Nov 6, 2020
@andrewrk andrewrk removed this from the 0.9.0 milestone May 19, 2021
@andrewrk andrewrk added this to the 0.10.0 milestone May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant