mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
cbe: add missing cast of overflow arithmetic out pointer
This commit is contained in:
committed by
Alex Rønne Petersen
parent
cfde9303ff
commit
1b55ca18ef
+19
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user