diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-08-16 05:31:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 23:31:44 +0200 |
commit | ade75a148332e670244a719202f7f0337d2e469a (patch) | |
tree | 7253b1ac09f225d946412412e281daae89838bb9 /lib | |
parent | 6c4e7835bf9c1fea608c1f9f55026095fcdd14b2 (diff) | |
download | Nim-ade75a148332e670244a719202f7f0337d2e469a.tar.gz |
fixes #22481; fixes `card` undefined misalignment behavior (#22484)
* fixes `card` undefined misalignment behavior * Update lib/system/sets.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/sets.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/system/sets.nim b/lib/system/sets.nim index 5f7c3e37b..97431c296 100644 --- a/lib/system/sets.nim +++ b/lib/system/sets.nim @@ -13,9 +13,11 @@ proc cardSetImpl(s: ptr UncheckedArray[uint8], len: int): int {.inline.} = var i = 0 result = 0 + var num = 0'u64 when defined(x86) or defined(amd64): while i < len - 8: - inc(result, countBits64((cast[ptr uint64](s[i].unsafeAddr))[])) + copyMem(addr num, addr s[i], 8) + inc(result, countBits64(num)) inc(i, 8) while i < len: |