valac generates reference to out-of-scope C local
Tested with 0.48.11 and PPA 0.50.0 nightly.
The following Vala method:
public bool funcall (string name, long? uniarg=null) {
assert (uniarg == null);
return LispFunc.find (name).func (((uniarg == null) ? 1 : uniarg), leNIL);
}
generates the following C:
gboolean
lisp_funcall (const gchar* name,
glong* uniarg)
{
glong* _tmp0_ = NULL;
LispFunc* _tmp2_;
LispFunc* _tmp3_;
LispFunction _tmp4_;
Lexp* _tmp5_;
gboolean _tmp6_;
gboolean result = FALSE;
g_return_val_if_fail (name != NULL, FALSE);
_vala_assert (uniarg == NULL, "uniarg == null");
if (uniarg == NULL) {
glong _tmp1_;
_tmp1_ = (glong) 1;
_tmp0_ = &_tmp1_;
} else {
_tmp0_ = uniarg;
}
_tmp2_ = lisp_func_find (name);
_tmp3_ = _tmp2_;
_tmp4_ = _tmp3_->func;
_tmp5_ = leNIL;
_tmp6_ = _tmp4_ (*_tmp0_, _tmp5_);
_lisp_func_unref0 (_tmp3_);
result = _tmp6_;
return result;
}
The problem here is that in the C, _tmp1_
is referred to implicitly after it goes out of scope.
(As usual, sorry if I overlooked a dupe—I searched for "scope", "variable", and tried the "Code generator" label. If I've managed to overlook a dupe again, I would appreciate hints on how I could search better!)