RFC: Avoid unwanted signed/unsigned conversion check in pointer + and - #8933
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.
After #8420, each use of
+(::Ptr,::Int)
and-(::Ptr,::Int)
includes a (probably unintentional) check for illegal signed/unsigned conversion: (maybe also for otherInteger
subtypes)I can only guess that this was not intended. Pointer arithmetic is inherently unsafe and impossible to check automatically, but it can be quite useful in tight hand-optimized loops, where the above check adds overhead and precludes further optimizations.
This patch brings back the previous, simple behavior:
I put RFC in the title to make sure that this is actually desirable to fix, and to get feedback on the way that I have fixed it:
UInt
has the same size as aPtr
. Afaik this is always the case in Julia, but should I rely on it?Btw, I noticed that
-(::Ptr,::Ptr)
gives an unsigned result. Might also be worth fixing?