GNOME Bugzilla – Bug 619461
Delegates with integer type arguments generate warnings
Last modified: 2018-05-17 06:06:55 UTC
Created attachment 161816 [details] test case The parameters of the delegate CompareFunc should be constant. Compiling the attached test case leads to the following cc compile warning: /home/simon/test-case.vala.c: In function ‘_vala_main’: /home/simon/test-case.vala.c:34: warning: passing argument 2 of ‘g_slist_sort’ from incompatible pointer type /usr/include/glib-2.0/glib/gslist.h:97: note: expected ‘GCompareFunc’ but argument is of type ‘gint (*)(void *, void *)’
I get the same compiler warning
This doesn't generate a warning due to a const mismatch anymore, however if the delegate parameters are ints (as they should be for this test case), the generated C does cause a couple of warnings like this: "warning: passing argument 1 of ‘cmp’ makes integer from pointer without a cast". We should probably be casting, ideally with GINT_TO_POINTER/GPOINTER_TO_INT.
Compiles without warning. So closing this bug. gint cmp (gint a, gint b) { gint result = 0; result = (gint) (a < b); return result; } static gint _cmp_gcompare_func (gconstpointer a, gconstpointer b) { gint result; result = cmp ((gint) ((gintptr) a), (gint) ((gintptr) b)); return result; }