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

Packed struct, size of field % 8 !=0, @byteOffsetOf does not include prior fields byte offset #5743

Closed
justinbalexander opened this issue Jun 28, 2020 · 3 comments

Comments

@justinbalexander
Copy link
Contributor

test "@byteOffsetOf packed struct, fields cross byte boundary" {
    const P = packed struct {
        a: u9,
        b: u7,
    };

    std.testing.expectEqual(0, @byteOffsetOf(P, "a"));
    std.testing.expectEqual(1, @byteOffsetOf(P, "b"));
}

I reference this in my (failing) pull request #5713. What is the intended behavior?

This issue is linked to issue #5742 as they both come out of the same code section which is resolve_struct_type where the offsets are calculated.

@daurnimator
Copy link
Contributor

Duplicate of #2627?

@justinbalexander
Copy link
Contributor Author

Yep totally a duplicate. I would still like to know whether this test should pass or if it is a bug.

@justinbalexander
Copy link
Contributor Author

Well I put in a pull request to fix the issue. It fixes byteOffset of. It's waiting to be reviewed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants