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

Add warning about GC to taggedPointer and taggedClassRef docs #3411

Merged
merged 1 commit into from
Jun 13, 2015

Conversation

schuetzm
Copy link
Contributor

@schuetzm schuetzm force-pushed the warning-tagged-ptr branch from 68f859c to 542a657 Compare June 13, 2015 12:50
@schuetzm
Copy link
Contributor Author

Includes trivial typo fix in the same section.

andralex added a commit that referenced this pull request Jun 13, 2015
Add warning about GC to taggedPointer and taggedClassRef docs
@andralex andralex merged commit f109d99 into dlang:master Jun 13, 2015
@schveiguy
Copy link
Member

I think this was a mistake. Pointer math is allowed, and pointer bitops with given preconditions are equivalent to pointer math.

I think we should revert this and fix the docs.

@dnadlinger
Copy link
Member

Pointer bitops that do not respect the alignment of the pointed-to type are not equivalent to normal (+, -, etc.) pointer arithmetic. This change is correct.

@schveiguy
Copy link
Member

It's not equivalent to pointer arithmetic, but we do allow pointer arithmetic to get the same result:

void *ptr = ptrToSomeInt;
ptr++;

This is allowed, and fundamentally must be. There is no difference here. In fact, the code could be reimplemented this way, and the result, as far as the GC cares, is the same. The GC docs are wrong IMO.

@schveiguy
Copy link
Member

I'll ask this: if the pointer is stored as a void *, does this warning go away? I am not actually sure it isn't, I can't tell from the code, because it's so meta.

@schuetzm schuetzm deleted the warning-tagged-ptr branch June 14, 2015 11:03
@deadalnix
Copy link
Contributor

That doesn't make any sense. The code specifically checks so that this is safe to do (you can only tag pointer withing the alignment, meaning you can't get a pointer past the end of the object).

Can we fix the GC doc rather than making this needlessly scary to use ? The GC cannot work if it can't handle that to begin with.

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

Successfully merging this pull request may close these issues.

5 participants