Skip to content

Commit 6286cfd

Browse files
oscardssmithKristofferC
authored andcommitted
fix pointerarith_tfunc for Const ptr (#60011)
fixes #60009 (cherry picked from commit 97f880a)
1 parent 2fc0ebd commit 6286cfd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Compiler/src/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function pointer_eltype(@nospecialize(ptr))
713713
end
714714

715715
@nospecs function pointerarith_tfunc(𝕃::AbstractLattice, ptr, offset)
716-
return ptr
716+
return widenconst(ptr)
717717
end
718718
@nospecs function pointerref_tfunc(𝕃::AbstractLattice, a, i, align)
719719
return pointer_eltype(a)

Compiler/test/effects.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,3 +1478,10 @@ let effects = Base.infer_effects((Core.SimpleVector,Int); optimize=false) do sve
14781478
end
14791479

14801480
@test Compiler.is_nothrow(Base.infer_effects(length, (Core.SimpleVector,)))
1481+
1482+
1483+
# https://github.com/JuliaLang/julia/issues/60009
1484+
function null_offset(offset)
1485+
Ptr{UInt8}(C_NULL) + offset
1486+
end
1487+
@test null_offset(Int(100)) == Ptr{UInt8}(UInt(100))

0 commit comments

Comments
 (0)