Bug in sysv abi when passing union in with floats #2784

This commit is contained in:
Christoffer Lerno
2026-01-21 00:34:37 +01:00
parent 1e11b6c442
commit 472124dab3
3 changed files with 49 additions and 1 deletions

View File

@@ -485,8 +485,13 @@ bool x64_contains_float_at_offset(LoweredType *type, unsigned offset)
static Type *x64_get_fp_type_at_offset(Type *type, unsigned ir_offset)
{
while (type->type_kind == TYPE_UNION)
{
Decl *decl = type->decl;
type = decl->strukt.members[decl->strukt.union_rep]->type;
}
if (!ir_offset && type_is_float(type)) return type;
if (type->type_kind == TYPE_STRUCT || type->type_kind == TYPE_UNION)
if (type->type_kind == TYPE_STRUCT)
{
Decl *element = x64_get_member_at_offset(type->decl, ir_offset);
return x64_get_fp_type_at_offset(lowered_member_type(element), ir_offset - element->offset);