diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-10-08 15:19:01 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-10-08 15:19:01 +0100 |
| commit | 8e4233b86a1e688facd23e7cf80ef9f6127dddaa (patch) | |
| tree | 3bebfa5e0539e3932a2796ff23ede00f60de4e11 /src/types.cpp | |
| parent | 6424966b7ad6f85dc56d72cf623276f788a1a157 (diff) | |
Correct union size
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/types.cpp b/src/types.cpp index bb9e95667..313c75a35 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1877,7 +1877,6 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) { return gb_clamp(t->Union.custom_align, 1, build_context.max_align); } - i64 max = union_tag_size(t); for_array(i, t->Union.variants) { Type *variant = t->Union.variants[i]; @@ -2126,12 +2125,13 @@ i64 type_size_of_internal(gbAllocator allocator, Type *t, TypePath *path) { } } - // NOTE(bill): Align to int - i64 size = align_formula(max, build_context.word_size); + // NOTE(bill): Align to tag + i64 tag_size = union_tag_size(t); + i64 size = align_formula(max, tag_size); // NOTE(bill): Calculate the padding between the common fields and the tag t->Union.variant_block_size = size - field_size; - size += type_size_of(allocator, t_int); + size += tag_size; size = align_formula(size, align); return size; } break; |