Skip to content

Unexpected allocation in Julia 1.9/1.10 #49241

Closed
@dpinol

Description

@dpinol

The code below does not allocate in Julia 1.8, but it allocates 16 bytes in Julia 1.9 and 48 in Julia 1.10.

struct S
    a::Vector{Int}
end

const i = S(Int[])

function f(a::S)::Int
    isempty(a.a) && return 1
    return error("we")
end
@allocated(f(i))
16
versioninfo()
Julia Version 1.9.0-rc2
Commit 72aec423c2a (2023-04-01 10:41 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 12 virtual core

Metadata

Metadata

Assignees

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