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

disallow pointer_from_objref on immutable values. fixes #15857 #25362

Merged
merged 4 commits into from
Jan 4, 2018

Conversation

JeffBezanson
Copy link
Sponsor Member

No description provided.

This seems to date from before the representation of tuple types
was changed in v0.4.
@JeffBezanson JeffBezanson added the kind:breaking This change will break code label Jan 3, 2018
@JeffBezanson JeffBezanson added this to the 1.0 milestone Jan 3, 2018
@JeffBezanson JeffBezanson force-pushed the jb/pointer_from_objref branch 2 times, most recently from 8b93035 to 1434340 Compare January 3, 2018 02:54
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 3, 2018

This seems stricter than necessary (we only might re-box isbits and unions thereof). Is that intentional for ensuring compatibility into v1.x?

@@ -61,7 +61,7 @@ Ref(x::Ptr{T}, i::Integer) where {T} = x + (i - 1) * Core.sizeof(T)
function unsafe_convert(P::Type{Ptr{T}}, b::RefValue{T}) where T
if isbits(T) || isbitsunion(T)
return convert(P, pointer_from_objref(b))
elseif _isleaftype(T)
elseif _isleaftype(T) && T.mutable
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that inferable?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly no, but can be fixed easily I think.

@test pointer_from_objref(b) == pointer_from_objref(b)
@test pointer_from_objref(b) != pointer_from_objref(b2)
@test pointer_from_objref(b) != pointer_from_objref(b3)
@test pointer_from_objref(b2) != pointer_from_objref(b3)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is necessary to verify that the test is working. perhaps use the direct ccall version here?

@JeffBezanson
Copy link
Sponsor Member Author

This seems stricter than necessary (we only might re-box isbits and unions thereof). Is that intentional for ensuring compatibility into v1.x?

Yes, and it also seems better to make the rule as simple as possible. If this is too annoying we can relax it later.

@JeffBezanson JeffBezanson merged commit 068f94b into master Jan 4, 2018
@JeffBezanson JeffBezanson deleted the jb/pointer_from_objref branch January 4, 2018 15:56
tkoolen added a commit to tkoolen/StaticArrays.jl that referenced this pull request Jan 10, 2018
tkoolen added a commit to tkoolen/StaticArrays.jl that referenced this pull request Jan 10, 2018
tkoolen added a commit to tkoolen/StaticArrays.jl that referenced this pull request Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:breaking This change will break code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants