diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 11f8ed1257..5ecf2ae122 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -2707,6 +2707,8 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as } if arg.expr.is_as_cast() { g.inside_smartcast = true + } else if arg_typ_sym.is_int() && arg.expr !is ast.CastExpr { + g.write('(voidptr)&') } else { g.write('ADDR(${g.styp(atype)}, ') needs_closing = true diff --git a/vlib/v/tests/concurrency/chan_try_push_int_test.v b/vlib/v/tests/concurrency/chan_try_push_int_test.v new file mode 100644 index 0000000000..8f37feaf51 --- /dev/null +++ b/vlib/v/tests/concurrency/chan_try_push_int_test.v @@ -0,0 +1,15 @@ +struct Foo { +mut: + value int = 123 +} + +fn test_main() { + shared m := Foo{} + ch := chan int{cap: 1} + ch.try_push(rlock m { + m.value + }) + mut tmp := int(0) + ch.try_pop(mut tmp) + assert tmp == 123 +}