aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2025-03-11 08:56:45 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2025-03-21 21:51:08 -0400
commited284c1f98ae08a36a7ef0776e22a4cfb2527fee (patch)
treea8615a86badb18c304182fdb90f4ffd8065b2c80 /src/codegen/c.zig
parent9c9d3931df4c1decffec610e5e47b3049b147c8d (diff)
downloadzig-ed284c1f98ae08a36a7ef0776e22a4cfb2527fee.tar.gz
zig-ed284c1f98ae08a36a7ef0776e22a4cfb2527fee.zip
big.int: fix yet another truncate bug
Too many bugs have been found with `truncate` at this point, so it was rewritten from scratch. Based on the doc comment, the utility of `convertToTwosComplement` over `r.truncate(a, .unsigned, bit_count)` is unclear and it has a subtle behavior difference that is almost certainly a bug, so it was deleted.
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index cd4573375d..2aee078b11 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -8175,7 +8175,7 @@ fn formatIntLiteral(
try writer.writeAll(string);
} else {
try data.ctype.renderLiteralPrefix(writer, data.kind, ctype_pool);
- wrap.convertToTwosComplement(int, data.int_info.signedness, c_bits);
+ wrap.truncate(int, .unsigned, c_bits);
@memset(wrap.limbs[wrap.len..], 0);
wrap.len = wrap.limbs.len;
const limbs_per_c_limb = @divExact(wrap.len, c_limb_info.count);
@@ -8207,7 +8207,6 @@ fn formatIntLiteral(
c_limb_int_info.signedness = .signed;
c_limb_ctype = c_limb_info.ctype.toSigned();
- c_limb_mut.positive = wrap.positive;
c_limb_mut.truncate(
c_limb_mut.toConst(),
.signed,