From 2fe660a1d7d9ca32eb4a4056b70fccdceb401d49 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 19 Jan 2018 17:11:28 +0000 Subject: Fix empty union IR bug --- src/ir.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 39d7e3e84..e66349de5 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8076,8 +8076,11 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info i64 tag_size = union_tag_size(a, t); i64 tag_offset = align_formula(t->Union.variant_block_size, tag_size); - ir_emit_store(proc, tag_offset_ptr, ir_const_uintptr(a, tag_offset)); - ir_emit_store(proc, tag_type_ptr, ir_type_info(proc, union_tag_type(a, t))); + + if (tag_size > 0) { + ir_emit_store(proc, tag_offset_ptr, ir_const_uintptr(a, tag_offset)); + ir_emit_store(proc, tag_type_ptr, ir_type_info(proc, union_tag_type(a, t))); + } } break; -- cgit v1.2.3