mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix codegen for struct field with a shared array of points (#13222)
This commit is contained in:
parent
ffb263c2e1
commit
cbd3c14e83
@ -6160,7 +6160,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string {
|
|||||||
noscan := g.check_noscan(elem_typ)
|
noscan := g.check_noscan(elem_typ)
|
||||||
init_str := '__new_array${noscan}(0, 0, sizeof($elem_type_str))'
|
init_str := '__new_array${noscan}(0, 0, sizeof($elem_type_str))'
|
||||||
if typ.has_flag(.shared_f) {
|
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))'
|
return '($atyp*)__dup_shared_array(&($atyp){.mtx = {0}, .val =$init_str}, sizeof($atyp))'
|
||||||
} else {
|
} else {
|
||||||
return init_str
|
return init_str
|
||||||
|
12
vlib/v/tests/shared_array_ptr_test.v
Normal file
12
vlib/v/tests/shared_array_ptr_test.v
Normal file
@ -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…
x
Reference in New Issue
Block a user