mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Correct union tag size for large alignments
This commit is contained in:
+2
-10
@@ -2208,7 +2208,6 @@ i64 union_tag_size(Type *u) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
// TODO(bill): Is this an okay approach?
|
// TODO(bill): Is this an okay approach?
|
||||||
i64 max_align = 1;
|
i64 max_align = 1;
|
||||||
for_array(i, u->Union.variants) {
|
for_array(i, u->Union.variants) {
|
||||||
@@ -2219,15 +2218,8 @@ i64 union_tag_size(Type *u) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u->Union.tag_size = gb_min(max_align, build_context.max_align);
|
u->Union.tag_size = gb_min3(max_align, build_context.max_align, 8);
|
||||||
return max_align;
|
return u->Union.tag_size;
|
||||||
#else
|
|
||||||
i64 bytes = next_pow2(cast(i64)(floor_log2(n)/8 + 1));
|
|
||||||
i64 tag_size = gb_max(bytes, 1);
|
|
||||||
|
|
||||||
u->Union.tag_size = tag_size;
|
|
||||||
return tag_size;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *union_tag_type(Type *u) {
|
Type *union_tag_type(Type *u) {
|
||||||
|
|||||||
Reference in New Issue
Block a user