From de39bba7bdb682ed851efcc73889f45b3507a545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kr=C3=BCger?= <45282134+UweKrueger@users.noreply.github.com> Date: Tue, 20 Jul 2021 07:30:07 +0200 Subject: [PATCH] v.gen.c: fix calling pointer receiver on function return result (#10866) --- vlib/v/gen/c/fn.v | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index a4a33714a7..189bcac634 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -762,7 +762,12 @@ fn (mut g Gen) method_call(node ast.CallExpr) { // Add `&` automatically. // TODO same logic in call_args() if !is_range_slice { - g.write('&') + if !node.left.is_lvalue() { + g.write('ADDR($rec_cc_type, ') + has_cast = true + } else { + g.write('&') + } } } else if !node.receiver_type.is_ptr() && node.left_type.is_ptr() && node.name != 'str' && node.from_embed_type == 0 {