|
@@ -124,8 +124,16 @@ gb_internal void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, u
|
|
|
switch (kind) {
|
|
|
case LLVMStructTypeKind:
|
|
|
case LLVMArrayTypeKind:
|
|
|
- // NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
|
|
|
- lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
|
|
|
+ if (is_type_tuple(type)) {
|
|
|
+ // NOTE(bill): even though this should be safe, to keep ASAN happy, do not zero the implicit padding at the end
|
|
|
+ GB_ASSERT(type->kind == Type_Tuple);
|
|
|
+ i64 n = type->Tuple.variables.count-1;
|
|
|
+ i64 end_offset = type->Tuple.offsets[n] + type_size_of(type->Tuple.variables[n]->type);
|
|
|
+ lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, end_offset).value, alignment, false);
|
|
|
+ } else {
|
|
|
+ // NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
|
|
|
+ lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
LLVMBuildStore(p->builder, LLVMConstNull(lb_type(p->module, type)), ptr);
|