Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ size(V::SubArray) = (@_inline_meta; map(n->Int(unsafe_length(n)), axes(V)))

similar(V::SubArray, T::Type, dims::Dims) = similar(V.parent, T, dims)

sizeof(V::SubArray) = length(V) * elsize(V.parent)
sizeof(V::SubArray) = length(V) * sizeof(eltype(V))
sizeof(V::SubArray{<:Any,<:Any,<:Array}) = length(V) * elsize(V.parent)

copy(V::SubArray) = V.parent[V.indices...]

Expand Down
6 changes: 5 additions & 1 deletion test/subarray.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, Random
using Test, Random, LinearAlgebra

######## Utilities ###########

Expand Down Expand Up @@ -601,6 +601,10 @@ end
arrayOfUInt48 = [a, b, c];

@test sizeof(view(arrayOfUInt48, 1:2)) == 16

@test sizeof(view(Diagonal(zeros(UInt8, 10)), 1:4)) == 4
@test sizeof(view(Diagonal(zeros(UInt8, 10)), 1:3)) == 3
@test sizeof(view(Diagonal(zeros(Float64, 10)), 1:3, 2:6)) == 120
end


Expand Down