diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 1a19f4aa10..718d3f4ba0 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -2427,17 +2427,13 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) { g.is_shared = var_type.has_flag(.shared_f) if !cloned { if is_fixed_array_copy { - i_var := g.new_tmp_var() - fixed_array := right_sym.info as ast.ArrayFixed - g.write('for (int $i_var=0; $i_var<$fixed_array.size; $i_var++) {') + typ_str := g.typ(val_type).trim('*') + ref_str := if val_type.is_ptr() { '' } else { '&' } + g.write('memcpy(($typ_str*)') g.expr(left) - g.write('[$i_var] = ') - if val.is_auto_deref_var() { - g.write('*') - } + g.write(', (byte*)$ref_str') g.expr(val) - g.write('[$i_var];') - g.writeln('}') + g.write(', sizeof($typ_str))') } else if is_decl { if is_fixed_array_init && !has_val { if val is ast.ArrayInit {