Skip to content

Commit

Permalink
Merge pull request #8933 from toivoh/pointer_arithmetic
Browse files Browse the repository at this point in the history
RFC: Avoid unwanted signed/unsigned conversion check in pointer + and -
  • Loading branch information
JeffBezanson committed Nov 10, 2014
2 parents a015cce + 8988f49 commit a1411ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ eltype{T}(::Ptr{T}) = T
==(x::Ptr, y::Ptr) = uint(x) == uint(y)
-(x::Ptr, y::Ptr) = uint(x) - uint(y)

+(x::Ptr, y::Integer) = oftype(x, uint(uint(x) + y))
-(x::Ptr, y::Integer) = oftype(x, uint(uint(x) - y))
+(x::Ptr, y::Integer) = oftype(x, (uint(x) + (y % UInt) % UInt))
-(x::Ptr, y::Integer) = oftype(x, (uint(x) - (y % UInt) % UInt))
+(x::Integer, y::Ptr) = y + x

zero{T}(::Type{Ptr{T}}) = convert(Ptr{T}, 0)
Expand Down

0 comments on commit a1411ca

Please sign in to comment.