diff --git a/src/host/broadcast.jl b/src/host/broadcast.jl index 7132863d..4498c6e6 100644 --- a/src/host/broadcast.jl +++ b/src/host/broadcast.jl @@ -114,7 +114,7 @@ function Base.map!(f, dest::AnyGPUArray, xs::AbstractArray...) # (avoids the reshape + view that our mapreduce impl has to do) indices = LinearIndices.((dest, xs...)) common_length = minimum(length.(indices)) - common_length==0 && return + common_length==0 && return dest bc = Broadcast.instantiate(Broadcast.broadcasted(f, xs...)) if bc isa Broadcast.Broadcasted diff --git a/test/testsuite/broadcasting.jl b/test/testsuite/broadcasting.jl index e892c69f..19e8b192 100644 --- a/test/testsuite/broadcasting.jl +++ b/test/testsuite/broadcasting.jl @@ -166,6 +166,9 @@ function broadcasting(AT, eltypes) @test compare(AT, rand(ET, 2), 1:2) do x, y map!(+, x, y) end + @test compare(AT, rand(ET, 0), rand(ET, 0)) do x, y + map!(+, x, y) + end end @testset "map $ET" begin @@ -178,6 +181,9 @@ function broadcasting(AT, eltypes) @test compare(AT, rand(ET, 2,2), rand(ET, 2)) do x,y map(+, x, y) end + @test compare(AT, rand(ET, 0), rand(ET, 2)) do x, y + map(+, x, y) + end # issue #580 @test compare(AT, rand(ET, 2), 1:2) do x, y map(+, x, y)