cbe: add missing cast of overflow arithmetic out pointer

This commit is contained in:
Matthew Lugg
2026-04-22 08:46:10 +01:00
committed by Alex Rønne Petersen
parent cfde9303ff
commit 1b55ca18ef
+19 -1
View File
@@ -3497,9 +3497,27 @@ fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info:
try w.writeAll(operation);
try w.writeAll("o_");
try f.dg.renderTypeForBuiltinFnName(w, scalar_ty);
try w.writeAll("(&");
try w.writeByte('(');
// '&dest', possibly preceded by a cast
switch (zcu.intern_pool.indexToKey(scalar_ty.toIntern())) {
.int_type => {}, // we already have a '[u]intX_t *'
.simple_type => {
// '&dest' will be something like a 'uintptr_t *', which might be a different C type to
// the equivalent sized integer (e.g. 'uint64_t *'), so we need a cast. We don't need a
// cast on the *operands* because they are passed by value (except for big integers,
// where this issue doesn't exist because no "simple" int type needs bigint repr).
try w.print("({s}int{d}_t *)", .{
if (scalar_ty.isUnsignedInt(zcu)) "u" else "",
scalar_ty.abiSize(zcu) * 8,
});
},
else => unreachable,
}
try w.writeByte('&');
try f.writeCValueMember(w, local, .{ .field = 0 });
try v.elem(f, w);
try w.writeAll(", ");
if (ref_arg) try w.writeByte('&');
try f.writeCValue(w, lhs, .other);