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 615450 - Variadic methods with no named arguments are accepted but do not work
Variadic methods with no named arguments are accepted but do not work
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Methods
0.8.x
Other All
: Normal minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-04-11 13:56 UTC by Nathan Baum
Modified: 2010-04-28 07:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Nathan Baum 2010-04-11 13:56:23 UTC
With the following non-member method declaration:

  void foo (...) {
    var l = va_list();
  }

valac does not consider it an error that the method has no named arguments, but the generated code does not work:

  #include <stdarg.h>
  
  void foo (...) {
    va_list l;
    va_start(l);
    va_end(l);
  }

The C code cannot be compiled because va_start is missing its required first argument. There is no way to access foo's arguments unless vala inserts a pretend argument in the C code, e.g.:

  void foo (void *marker, ...) {
    va_list l;
    va_start(l, marker);
    va_end(l);
  }

vala could automatically insert the argument into invocations of foo(), but people using vala functions from C would have to provide that argument themselves, which is ugly. The other option appears to be refusing to allow a variadic method to be declared without any named arguments.

A member method always has the instance passed as the first argument, so foo could in principle work as a member method. valac currently doesn't generate appropriate code for that:

  void test_foo (Test *self, ...) {
    va_list l;
    va_start(l);
    va_end(l);
  }

Presumably it would be a simple fix to make va_list work in this case.

It might be desirable not to fix it, though, for consistency with not allowing variadic non-member methods without named arguments.
Comment 1 Jürg Billeter 2010-04-28 07:34:29 UTC
commit 924da8c8281c169a74c1c13a3eb13755530d316c
Author: Jürg Billeter <j@bitron.ch>
Date:   Wed Apr 28 09:32:39 2010 +0200

    Report error when using ellipsis without named parameter
    
    Fixes bug 615450.