diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-16 14:58:37 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-16 14:58:37 -0400 |
| commit | a418dfdc658a2cc9cc1d1b4a95f1167be6054bbb (patch) | |
| tree | 06b27a513ad43632383b919ba009edd52606669f /src | |
| parent | b2af4bc802e13202a5973a214efab77a451188a8 (diff) | |
Bugfix for optionals that have alignment issues
Diffstat (limited to 'src')
| -rw-r--r-- | src/stdlib/optionals.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stdlib/optionals.c b/src/stdlib/optionals.c index 7df9a827..3c595893 100644 --- a/src/stdlib/optionals.c +++ b/src/stdlib/optionals.c @@ -14,7 +14,10 @@ public PUREFUNC bool is_none(const void *obj, const TypeInfo_t *non_optional_typ if (non_optional_type->metamethods.is_none) return non_optional_type->metamethods.is_none(obj, non_optional_type); - return *(bool*)(obj + non_optional_type->size); + const void *dest = (obj + non_optional_type->size); + if (non_optional_type->align > 0 && (int64_t)dest % non_optional_type->align) + dest += (non_optional_type->align - ((int64_t)dest % non_optional_type->align)); + return *(bool*)dest; } PUREFUNC public uint64_t Optional$hash(const void *obj, const TypeInfo_t *type) |
