diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 13ff4e7344..6df3893cbe 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -4108,6 +4108,8 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { if (is_reg) { try f.writeCValue(writer, .{ .local = locals_index }, .Other); locals_index += 1; + } else if (output == .none) { + try f.writeCValue(writer, local, .FunctionArgument); } else { try f.writeCValueDeref(writer, try f.resolveInst(output)); } @@ -4411,6 +4413,10 @@ fn structFieldPtr(f: *Function, inst: Air.Inst.Index, struct_ptr_ty: Type, struc u8_ptr_pl.data.pointee_type = Type.u8; const u8_ptr_ty = Type.initPayload(&u8_ptr_pl.base); + if (!std.mem.isAligned(byte_offset, field_ptr_ty.ptrAlignment(target))) { + return f.fail("TODO: CBE: unaligned packed struct field pointer", .{}); + } + try writer.writeAll("&(("); try f.renderTypecast(writer, u8_ptr_ty); try writer.writeByte(')');