After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 638310 - Vala generates invalid C when accessing out param 'foo' and declaring local '_foo'
Vala generates invalid C when accessing out param 'foo' and declaring local '...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.11.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-12-29 22:26 UTC by Travis Reitter
Modified: 2011-07-28 10:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2010-12-29 22:26:10 UTC
valac turns this Vala into the following C:

  private void foo (out string? bar)
    {
      string _bar = "baz qux";
     
      if (bar == "xyz")
        warning ("invalid string '%s'", bar);
    }

=>

static void folks_inspect_commands_signals_foo (FolksInspectCommandsSignals* self, gchar** bar) {
  gchar* _bar = NULL;
  gchar* _tmp0_;
  /* XXX: second declaration of _bar, for the local variable declared in Vala */
  gchar* _bar;
  g_return_if_fail (self != NULL);
  _tmp0_ = g_strdup ("baz qux");
  _bar = _tmp0_;
  if (g_strcmp0 (_bar, "xyz") == 0) {
    g_warning ("command-signals.vala:198: invalid string '%s'", _bar);
  }
  _g_free0 (_bar);
  if (bar) {
    *bar = _bar;
  } else {
    _g_free0 (_bar);
  }
}

==============================

The problem is that the out parameter "bar" creates a temporary variable "_bar" in C, which conflicts with the declaration of the local variable "_bar".
Comment 1 Luca Bruno 2011-07-28 10:46:34 UTC
commit 07ad39b7ba5db54aa9e7cc91035ff7d2c51f693b
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Thu Jul 28 12:45:39 2011 +0200

    codegen: Use _vala_ prefix for out parameters
    
    Fixes bug 638310.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.