diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 490943bc51..981f3cbda4 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -6160,7 +6160,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string { noscan := g.check_noscan(elem_typ) init_str := '__new_array${noscan}(0, 0, sizeof($elem_type_str))' if typ.has_flag(.shared_f) { - atyp := '__shared__Array_${g.table.sym(elem_typ).cname}' + atyp := '__shared__$sym.cname' return '($atyp*)__dup_shared_array(&($atyp){.mtx = {0}, .val =$init_str}, sizeof($atyp))' } else { return init_str diff --git a/vlib/v/tests/shared_array_ptr_test.v b/vlib/v/tests/shared_array_ptr_test.v new file mode 100644 index 0000000000..27f11f4635 --- /dev/null +++ b/vlib/v/tests/shared_array_ptr_test.v @@ -0,0 +1,12 @@ +struct AA { +mut: + a shared []&int +} + +fn test_shared_array_ptr() { + mut a := AA{} + b := 3 + lock a.a { + a.a << &b + } +}