You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perform a conservative test to check if arrays A and B might share the same memory.
Yet, its default implementation basically always returns false , even for objects that does alias:
julia>struct Foo <:AbstractVector{Int}
x::Vector{Int}end;
julia> x = [1,2];
julia> Base.mightalias(x, Foo(x))
false
julia> d =Dict();
julia> Base.mightalias(d, d.keys)
false
I think this is a problem. Presumably, mightalias is going to be used as a guard to prevent aliasing bugs. Having it claim to be conservative, but actually falsely return false for most arguments is a huge footgun.
Luckily for this issue, Base.mightalias does not appear to be documented in the official Julia docs, so it's fair game to change. I believe the best course of action is to remove the default fallback implementation(s) for this and Base.dataids.
Yes, the aliasing detection system is opt-in. Once you opt-in, it is a conservative check. Perhaps that one-sentence summary should be clearer, but the rest of the docstring is trying to describe this:
By default, this simply checks if either of the arrays reference the same memory regions, as identified by their Base.dataids.
I fought for a long time trying to come up with a better default fallback, but it is extraordinarily hard to do so. See #26237. Removing the default fallbacks is highly breaking, even in situations where no aliasing occurs.
Base.mightalias
's docstring says (my emphasis)Yet, its default implementation basically always returns false , even for objects that does alias:
I think this is a problem. Presumably,
mightalias
is going to be used as a guard to prevent aliasing bugs. Having it claim to be conservative, but actually falsely returnfalse
for most arguments is a huge footgun.Luckily for this issue,
Base.mightalias
does not appear to be documented in the official Julia docs, so it's fair game to change. I believe the best course of action is to remove the default fallback implementation(s) for this andBase.dataids
.See also: #26865
The text was updated successfully, but these errors were encountered: