Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 22, 2025
1 parent fcc323d commit a264e3d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -2769,9 +2769,12 @@ fn (mut g Gen) expr_with_fixed_array(expr ast.Expr, got_type_raw ast.Type, expec
// [ foo(), foo() ]!
val_typ := g.table.value_type(got_type_raw)
val_styp := g.styp(val_typ)
val_sym := g.table.final_sym(val_typ)
prefix := if val_sym.kind !in [.array, .array_fixed] { '&' } else { '' }
for i, item_expr in expr.exprs {
g.write('memcpy(&${tmp_var}[${i}], ')
needs_addr := (item_expr is ast.CallExpr && !item_expr.return_type.is_ptr())
g.write('memcpy(${prefix}${tmp_var}[${i}], ')
needs_addr := (item_expr is ast.CallExpr && !item_expr.return_type.is_ptr()
&& g.table.final_sym(item_expr.return_type).kind !in [.array, .array_fixed])
|| (item_expr is ast.InfixExpr && !item_expr.promoted_type.is_ptr())
|| item_expr is ast.StructInit
if needs_addr {
Expand Down

0 comments on commit a264e3d

Please sign in to comment.