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

byteOffsetOf following non-abi-pointer-size-multiple array #5713

Open
wants to merge 2 commits into
base: master
from

Conversation

@vegecode
Copy link
Contributor

vegecode commented Jun 25, 2020

The second commit contains a test of @byteOffsetOf that resulted in a counter-intuitive answer (to me at least). Is that the intended behavior?

@vegecode vegecode force-pushed the vegecode:byteOffsetOf_fix branch from 4b62007 to c731320 Jun 26, 2020
@vegecode
Copy link
Contributor Author

vegecode commented Jun 26, 2020

Trying to figure out what I'm missing here.

Can somebody confirm that the result of the test cases I added in the second commit are correct or if that is unintended behaviour?

@vegecode vegecode force-pushed the vegecode:byteOffsetOf_fix branch from c731320 to c81cad4 Jul 4, 2020
@vegecode
Copy link
Contributor Author

vegecode commented Jul 4, 2020

Note this is still broken:

    var p: P = undefined;
    expectEqual(@ptrToInt(&p.i) - @ptrToInt(&p) = @byteOffsetOf(P, "i"));
Test [2/12] test "@byteOffsetOf"...expected 11, found 12

This case could be said to be undefined behavior perhaps, but it's also broken when the first field is an array of bytes.

@vegecode
Copy link
Contributor Author

vegecode commented Jul 9, 2020

Bump. Ready to inspect.

The address of a packed struct member is a different, although related, issue. Regardless of how that one is fixed, this change will still make sense I think.

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

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.