diff --git a/crates/compiler/builtins/bitcode/src/utils.zig b/crates/compiler/builtins/bitcode/src/utils.zig index 3d7733c2e4..78d18b95bf 100644 --- a/crates/compiler/builtins/bitcode/src/utils.zig +++ b/crates/compiler/builtins/bitcode/src/utils.zig @@ -337,7 +337,7 @@ inline fn free_ptr_to_refcount( inline fn decref_ptr_to_refcount( refcount_ptr: [*]isize, - alignment: u32, + element_alignment: u32, elements_refcounted: bool, ) void { if (RC_TYPE == Refcount.none) return; @@ -346,6 +346,10 @@ inline fn decref_ptr_to_refcount( std.debug.print("| decrement {*}: ", .{refcount_ptr}); } + // Due to RC alignmen tmust take into acount pointer size. + const ptr_width = @sizeOf(usize); + const alignment = @max(ptr_width, element_alignment); + // Ensure that the refcount is not whole program lifetime. const refcount: isize = refcount_ptr[0]; if (refcount != REFCOUNT_MAX_ISIZE) {