From 7cdca8f32c0615f3856748c1c1d0c053bdf92f4a Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 22 Jun 2023 18:28:03 -0500 Subject: [PATCH] bugfix: tagged unions alignment not always respected --- compiler/src/types.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- 2.25.1