Skip to content

Warn on uninitialized isbits-fields in structs? #24943

@KristofferC

Description

@KristofferC

For example:

julia> struct S
           a::Int
           b::Bool
           S(a::Int, b::Bool) = new(a)
       end

julia> S(1, false)
S(1, true)

Would it make any sense to warn that the struct S is being created with an uninitialized isbits-field?
The problem is that this will act like a well formed type but there is garbage memory in S.b. It seems like an easy mistake: add a field to the struct, forget to update the new call, use garbage memory that might work in 99% of the cases. Perhaps there could be a way to enforce being explicit about using uninitialized isbits field, like new(a, uninitialized) or something...

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