Skip to content

Commit 36ca628

Browse files
authored
cgen: fix codegen for passing int from selector to voidptr expect arg (fix #25081) (#25083)
1 parent 7b77f2e commit 36ca628

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

vlib/v/gen/c/fn.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,8 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
27072707
}
27082708
if arg.expr.is_as_cast() {
27092709
g.inside_smartcast = true
2710+
} else if arg_typ_sym.is_int() && arg.expr !is ast.CastExpr {
2711+
g.write('(voidptr)&')
27102712
} else {
27112713
g.write('ADDR(${g.styp(atype)}, ')
27122714
needs_closing = true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct Foo {
2+
mut:
3+
value int = 123
4+
}
5+
6+
fn test_main() {
7+
shared m := Foo{}
8+
ch := chan int{cap: 1}
9+
ch.try_push(rlock m {
10+
m.value
11+
})
12+
mut tmp := int(0)
13+
ch.try_pop(mut tmp)
14+
assert tmp == 123
15+
}

0 commit comments

Comments
 (0)