diff --git a/stdlib/LinearAlgebra/src/matmul.jl b/stdlib/LinearAlgebra/src/matmul.jl index 4fed8a577bd638..27bd9c2f23b153 100644 --- a/stdlib/LinearAlgebra/src/matmul.jl +++ b/stdlib/LinearAlgebra/src/matmul.jl @@ -823,7 +823,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat tile_size = 0 if isbitstype(R) && isbitstype(T) && isbitstype(S) && (tA == 'N' || tB != 'N') - tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T)))) + tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T), 1))) end @inbounds begin if tile_size > 0 diff --git a/stdlib/LinearAlgebra/test/matmul.jl b/stdlib/LinearAlgebra/test/matmul.jl index 6a81222174e1fe..107c579ba1f942 100644 --- a/stdlib/LinearAlgebra/test/matmul.jl +++ b/stdlib/LinearAlgebra/test/matmul.jl @@ -720,6 +720,16 @@ end @test D ≈ C end +@testset "size zero types in matrix mult (see issue 39362)" begin + A = [missing missing; missing missing] + v = [missing, missing] + @test (A * v == v) === missing + M = fill(1.0, 2, 2) + a = fill(missing, 2, 1) + @test (a' * M * a == fill(missing,1,1)) === missing +end + + @testset "multiplication of empty matrices without calling zero" begin r, c = rand(0:9, 2) A = collect(Number, rand(r, c))