aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-09-04 18:48:11 +0200
committerLaytan <laytanlaats@hotmail.com>2024-09-04 18:48:11 +0200
commit578de0977527a9cef7d1d77fab785363997b7cb6 (patch)
treea60866e93c308cf053afc0d1a7563e0a846a917e
parentdcf339517e5139a07cc45a2835567538b716d45c (diff)
types with explicit custom alignment are identical to types with the same natural alignment
-rw-r--r--src/types.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 21dd6ad39..63182f5c4 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -2810,8 +2810,14 @@ gb_internal bool are_types_identical_internal(Type *x, Type *y, bool check_tuple
case Type_Union:
if (x->Union.variants.count == y->Union.variants.count &&
- x->Union.custom_align == y->Union.custom_align &&
x->Union.kind == y->Union.kind) {
+
+ if (x->Union.custom_align != y->Union.custom_align) {
+ if (type_align_of(x) != type_align_of(y)) {
+ return false;
+ }
+ }
+
// NOTE(bill): zeroth variant is nullptr
for_array(i, x->Union.variants) {
if (!are_types_identical(x->Union.variants[i], y->Union.variants[i])) {
@@ -2827,10 +2833,16 @@ gb_internal bool are_types_identical_internal(Type *x, Type *y, bool check_tuple
x->Struct.is_no_copy == y->Struct.is_no_copy &&
x->Struct.fields.count == y->Struct.fields.count &&
x->Struct.is_packed == y->Struct.is_packed &&
- x->Struct.custom_align == y->Struct.custom_align &&
x->Struct.soa_kind == y->Struct.soa_kind &&
x->Struct.soa_count == y->Struct.soa_count &&
are_types_identical(x->Struct.soa_elem, y->Struct.soa_elem)) {
+
+ if (x->Struct.custom_align != y->Struct.custom_align) {
+ if (type_align_of(x) != type_align_of(y)) {
+ return false;
+ }
+ }
+
for_array(i, x->Struct.fields) {
Entity *xf = x->Struct.fields[i];
Entity *yf = y->Struct.fields[i];