aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 3cc077f84..f3b7f5bab 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -3326,6 +3326,9 @@ gb_internal bool are_struct_fields_reordered(Type *type) {
type = base_type(type);
GB_ASSERT(type->kind == Type_Struct);
type_set_offsets(type);
+ if (type->Struct.fields.count == 0) {
+ return false;
+ }
GB_ASSERT(type->Struct.offsets != nullptr);
i64 prev_offset = 0;
@@ -3344,6 +3347,9 @@ gb_internal Slice<i32> struct_fields_index_by_increasing_offset(gbAllocator allo
type = base_type(type);
GB_ASSERT(type->kind == Type_Struct);
type_set_offsets(type);
+ if (type->Struct.fields.count == 0) {
+ return {};
+ }
GB_ASSERT(type->Struct.offsets != nullptr);
auto indices = slice_make<i32>(allocator, type->Struct.fields.count);