mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-12 02:40:41 -04:00
Zero the extra bytes when widening a value in OdinLLVMBuildTransmute
This commit is contained in:
1 parent
12227d8484
commit
f254e28068
1 file changed
+4
@@ -3885,6 +3885,10 @@ general_end:;
|
||||
max_align = gb_max(max_align, 16);
|
||||
|
||||
LLVMValueRef ptr = llvm_alloca(p, dst_type, max_align);
|
||||
if (dst_size > src_size) {
|
||||
// NOTE(bill): the bytes past `src` are padding and must read as zero
|
||||
LLVMBuildStore(p->builder, LLVMConstNull(dst_type), ptr);
|
||||
}
|
||||
|
||||
LLVMValueRef nptr = LLVMBuildPointerCast(p->builder, ptr, LLVMPointerType(src_type, 0), "");
|
||||
LLVMBuildStore(p->builder, val, nptr);
|
||||
|
||||
Reference in new issue
Block a user