Skip to content

isbitstype vs Base.allocatedinline #23

@nielsls

Description

@nielsls

UnsafeArrays currently only support types T for isbitstype(T) == true.
I suppose the reason for this is that non-bits types are at risk of being GC'ed if their only reference is within an UnsafeArray.

However, this seems overly restrictive as isbitstype returns false for a lot of types (Unions of bitstypes, Ptrs, ..) that are allocated inline and thus not are in risk of being GC'ed. Instead, Base.allocatedinline seems like a better alternative.

E.g.

julia> struct Foo
           x::Union{Int, Nothing}
       end

julia> sizeof(Foo) # 16
16

julia> isbitstype(Foo) # false
false

julia> Base.allocatedinline(Foo) # true
true

julia> isbitstype(Ptr{Int}) # false
true

julia> Base.allocatedinline(Ptr{Int}) # true
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions