From a13e2bce1ea61a31b11c048bff2ff637d378b39e Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Thu, 25 Jun 2026 23:24:55 +0100 Subject: [PATCH] Fied segmentation fault --- i386.c | 17 +++++------------ parse.c | 5 ++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/i386.c b/i386.c index f656c2a..cfa5531 100644 --- a/i386.c +++ b/i386.c @@ -18102,6 +18102,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { if (tok.kind == TOK_ASSIGN) { int lhs_deref_is_unsigned = 1; + int lhs_deref_is_aggregate = 0; + lhs_sym = find_local_symbol (lhs_name); if (lhs_sym) { @@ -18110,6 +18112,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { deref_size = DATA_PTR & 0x1f; } else if (lhs_sym->pointer_depth == 1 && lhs_sym->pointed_size > 0) { + lhs_deref_is_aggregate = (lhs_sym->pointed_tag_name != 0); + /** * Keep the full pointed-to object size here. This * assignment path also handles aggregate lvalues such @@ -18161,7 +18165,7 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { get_token (); - if (deref_size > (DATA_LLONG & 0x1f)) { + if (lhs_deref_is_aggregate || deref_size > (DATA_LLONG & 0x1f)) { emit_pop_reg_now ("edx"); @@ -24087,15 +24091,6 @@ static void emit_load_assignment_rhs_expression_to_reg (const char *reg) { int true_label; int end_label; - if (current_expression_mentions_64bit_symbol_now ()) { - - const char *hi = (strcmp (reg, "edx") == 0) ? "ecx" : "edx"; - - emit_load_assignment_rhs_expression_to_pair (reg, hi, rhs_current_operand_is_unsigned_now ()); - return; - - } - if (rhs_current_operand_is_floating_now ()) { emit_load_floating_rhs_expression_now (DATA_DOUBLE & 0x1f); @@ -33563,8 +33558,6 @@ static void parse_statement (void) { } else if (current_function_return_size == (DATA_LLONG & 0x1f)) { emit_load_assignment_rhs_expression_to_pair ("eax", "edx", current_function_return_is_unsigned); - } else if (current_expression_mentions_64bit_symbol_now ()) { - emit_load_assignment_rhs_expression_to_pair ("eax", "edx", current_function_return_is_unsigned); } else { emit_load_assignment_rhs_expression_to_reg ("eax"); } diff --git a/parse.c b/parse.c index a0e96a2..7a8084d 100644 --- a/parse.c +++ b/parse.c @@ -1920,7 +1920,10 @@ int resolve_enum_constant (const char *name, int64_s *out) { } if (out) { - *out = entry->value; + + out->low = entry->value.low; + out->high = entry->value.high; + } return 1; -- 2.34.1