GNOME Bugzilla – Bug 615450
Variadic methods with no named arguments are accepted but do not work
Last modified: 2010-04-28 07:34:29 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.
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.