From: Brendan Hansen Date: Thu, 22 Jun 2023 23:28:03 +0000 (-0500) Subject: bugfix: tagged unions alignment not always respected X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=7cdca8f32c0615f3856748c1c1d0c053bdf92f4a;p=onyx.git bugfix: tagged unions alignment not always respected --- diff --git a/compiler/src/types.c b/compiler/src/types.c index 073da57a..29c955a9 100644 --- a/compiler/src/types.c +++ b/compiler/src/types.c @@ -805,6 +805,9 @@ static Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b bh_arr_push(tag_enum_node->values, ev); } + alignment = bh_max(alignment, 4); + bh_align(size, alignment); + u_type->Union.alignment = alignment; u_type->Union.size = size + alignment; // Add the size of the tag u_type->Union.tag_type = type_build_from_ast(alloc, (AstType *) tag_enum_node);