From 135d86349bcb8ab4c778bf81fc28a16ae74d4c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gr=C3=A9goire?= Date: Thu, 14 May 2026 09:01:42 -0400 Subject: [PATCH] rtl: fix bug in bitmap --- src/rtl/bitmap.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rtl/bitmap.zig b/src/rtl/bitmap.zig index a8d8cf4..b6e1dc3 100644 --- a/src/rtl/bitmap.zig +++ b/src/rtl/bitmap.zig @@ -11,8 +11,9 @@ pub fn BitMap(comptime N: usize) type { pub const Word = if (N > 32) u64 else get_closest_type(N); const Self = @This(); const bits_per_word = @bitSizeOf(Word); + const arr_len = (N + bits_per_word - 1) / bits_per_word; - storage: [bits_per_word / N]Word, + storage: [arr_len]Word, /// Initialize a bitmap, setting all bits to `val`. pub fn init(val: bool) Self { @@ -65,6 +66,7 @@ test "BitMap has proper underlying type" { std.debug.assert(BitMap(32).Word == u32); std.debug.assert(BitMap(64).Word == u64); std.debug.assert(BitMap(128).Word == u64); + std.debug.assert(BitMap(1024).Word == u64); } test BitMap {