Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
vala
vala
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 702
    • Issues 702
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 38
    • Merge Requests 38
  • Operations
    • Operations
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • GNOME
  • valavala
  • Issues
  • #1084

Closed
Open
Opened Oct 13, 2020 by Reuben Thomas@rrtContributor

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!)

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: GNOME/vala#1084