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
vegecode opened this issue Jun 28, 2020 · 3 comments

Comments

@vegecode
Copy link
Contributor

@vegecode vegecode commented Jun 28, 2020

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
Collaborator

@daurnimator daurnimator commented Jun 28, 2020

Duplicate of #2627?

@vegecode
Copy link
Contributor Author

@vegecode vegecode commented Jun 29, 2020

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

@vegecode
Copy link
Contributor Author

@vegecode vegecode commented Jul 9, 2020

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

@vegecode vegecode closed this Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.