cgen: fix codegen for struct field with a shared array of points (#13222)
parent
ffb263c2e1
commit
cbd3c14e83
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue