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

copy! is wrong for overlapping views #20069

Closed
stevengj opened this issue Jan 16, 2017 · 4 comments
Closed

copy! is wrong for overlapping views #20069

stevengj opened this issue Jan 16, 2017 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@stevengj
Copy link
Member

The copy! function has special-casing to handle the case where the source and destination arrays are equal, but this machinery does not work for views:

julia> a = [1:10;]; copy!(a, 2, a, 1, 9)
10-element Array{Int64,1}:
 1
 1
 2
 3
 4
 5
 6
 7
 8
 9

julia> a = [1:10;]; v = view(a, 1:10); copy!(v, 2, v, 1, 9)
10-element SubArray{Int64,1,Array{Int64,1},Tuple{UnitRange{Int64}},true}:
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
@stevengj stevengj added the bug Indicates an unexpected problem or unintended behavior label Jan 16, 2017
@Keno
Copy link
Member

Keno commented Jul 28, 2018

@mbauman Can some of your new alias detection logic handle this case, or does it already?

@mbauman
Copy link
Sponsor Member

mbauman commented Jul 30, 2018

Nope, looks like I missed copyto! in implementing the detection. Should be as easy as adding an src′ = unalias(dest, src) line there.

@StefanKarpinski
Copy link
Sponsor Member

I'm pretty sure that it's no longer a performance trap to just reuse the src name here.

@KristofferC
Copy link
Sponsor Member

Dup of #16705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants