aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-05-05 18:09:54 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2025-05-05 18:09:54 +0200
commit2224911aca77d15cfdb5ae19e16e9c88ed6edea9 (patch)
treee629da0bfd4c9ff6629ef4e1ef3d8c4ffcccca9e /src/check_builtin.cpp
parentc4719e75fd1cc209b46ec3844110e1d87266c5d2 (diff)
Fix `type_union_tag_offset` when all members are zero sized
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 9d07de2b6..a315d1880 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -6032,12 +6032,13 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
// NOTE(jakubtomsu): forces calculation of variant_block_size
type_size_of(u);
- i64 tag_offset = u->Union.variant_block_size;
- GB_ASSERT(tag_offset > 0);
+ // NOTE(Jeroen): A tag offset of zero is perfectly fine if all members of the union are empty structs.
+ // What matters is that the tag size is > 0.
+ GB_ASSERT(u->Union.tag_size > 0);
operand->mode = Addressing_Constant;
operand->type = t_untyped_integer;
- operand->value = exact_value_i64(tag_offset);
+ operand->value = exact_value_i64(u->Union.variant_block_size);
}
break;