diff --git a/nac3core/src/codegen/model/ptr.rs b/nac3core/src/codegen/model/ptr.rs index 0684892c..d0b2eeba 100644 --- a/nac3core/src/codegen/model/ptr.rs +++ b/nac3core/src/codegen/model/ptr.rs @@ -175,8 +175,16 @@ impl<'ctx, Item: Model<'ctx>> Instance<'ctx, Ptr> { source: Self, num_items: IntValue<'ctx>, ) { + let llvm_usize = generator.get_size_type(ctx.ctx); + + // Force extend `num_items` and `itemsize` so their types would match. let itemsize = self.model.sizeof(generator, ctx.ctx); - let totalsize = ctx.builder.build_int_mul(itemsize, num_items, "totalsize").unwrap(); // TODO: Int types may not match. + let itemsize = + ctx.builder.build_int_z_extend_or_bit_cast(itemsize, llvm_usize, "").unwrap(); + let num_items = + ctx.builder.build_int_z_extend_or_bit_cast(num_items, llvm_usize, "").unwrap(); + + let totalsize = ctx.builder.build_int_mul(itemsize, num_items, "totalsize").unwrap(); let is_volatile = ctx.ctx.bool_type().const_zero(); // is_volatile = false call_memcpy_generic(ctx, self.value, source.value, totalsize, is_volatile);