Skip to content

Commit

Permalink
ircode: fix regression (crash) from Memory{T} PR (JuliaLang#52409)
Browse files Browse the repository at this point in the history
The offset should be in elements not bytes.
  • Loading branch information
vtjnash committed Dec 6, 2023
1 parent cfcc043 commit fd9d3c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ircode.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void jl_encode_memory_slice(jl_ircode_state *s, jl_genericmemory_t *mem,
}
else {
ios_write(s->s, (char*)mem->ptr + offset * layout->size, len * layout->size);
if (jl_genericmemory_isbitsunion(mem))
if (layout->flags.arrayelem_isunion)
ios_write(s->s, jl_genericmemory_typetagdata(mem) + offset, len);
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ static void jl_encode_value_(jl_ircode_state *s, jl_value_t *v, int as_literal)
if (layout->flags.arrayelem_isunion || layout->size == 0)
offset = (uintptr_t)ar->ref.ptr_or_offset;
else
offset = (char*)ar->ref.ptr_or_offset - (char*)ar->ref.mem->ptr;
offset = ((char*)ar->ref.ptr_or_offset - (char*)ar->ref.mem->ptr) / layout->size;
jl_encode_memory_slice(s, ar->ref.mem, offset, l);
}
else if (as_literal && jl_is_genericmemory(v)) {
Expand Down

0 comments on commit fd9d3c0

Please sign in to comment.