Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
A way forward for pointer equality in const eval #73398
A way forward for pointer equality in const eval #73398
Changes from 5 commits
9245ba8
e09b620
84f1d73
9e88b48
53686b9
98e97a4
e465b22
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can unsafe code rely on a return value of
true
(similar to relying onstd::mem::needs_drop
returningfalse
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can. The comment says
I thought that was clear enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a non-obvious reason you
ptrtoint
before comparing?icmp
can work fine with pointer types, as long as the pointee types match, which in this case they should.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. I didn't know that. I basically grabbed this off
rust/src/librustc_codegen_llvm/intrinsic.rs
Lines 734 to 748 in 38bd83d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. LLVM supports comparison of pointer types but not subtraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So confusing. There's probably a good reason for that, but still... So many inconsistencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, there's a plan to add a
psub
operation that directly subtracts pointers. ;)(There is no pointer addition, either. Instead there is
getelementptr
as the specific instruction to do pointer arithmetic. That makes a lot of sense IMO.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this implementation will also be used by Miri, which is a bug. Can we somehow make it be used only during CTCE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't miri fall back to this only if it has no own impl? So we can just give miri an impl that behaves differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miri prefers the CTFE impls, to make sure we test those properly.
I am working on a PR that adds these to Miri in a way that it prefers its own impls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is: rust-lang/miri#1459