From b599a1a4db102f33dacf41cd5e75103f3d98342f Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:26:29 +0800 Subject: [PATCH] progress --- lib/system/gc.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 1a0e16802d..a449ccdba8 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -470,7 +470,9 @@ proc allocCellWithAlignment(typ: PNimType, size: int, gch: var GcHeap): PCell {. let base = rawAlloc(gch.region, size +% sizeof(Cell) +% extra) # calculate offset to align the user data (after the Cell header) # the user data starts at (base + sizeof(Cell)), so we align that address - let offset = requiredAlign -% cast[int]((cast[uint](base) + cast[uint](sizeof(Cell))) and cast[uint](extra)) + let userDataAddr = cast[uint](base) + cast[uint](sizeof(Cell)) + let misalignment = userDataAddr and cast[uint](extra) + let offset = requiredAlign -% cast[int](misalignment) result = cast[PCell](base +! offset) proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer =