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 619461 - Delegates with integer type arguments generate warnings
Delegates with integer type arguments generate warnings
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Delegates
0.8.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 664084
 
 
Reported: 2010-05-23 21:41 UTC by Simon Wenner
Modified: 2018-05-17 06:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (136 bytes, text/x-vala)
2010-05-23 21:41 UTC, Simon Wenner
Details

Description Simon Wenner 2010-05-23 21:41:36 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 *)’
Comment 1 Adam B 2010-07-10 04:29:06 UTC
I get the same compiler warning
Comment 2 Evan Nemerson 2014-01-29 05:33:49 UTC
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.
Comment 3 Rico Tzschichholz 2018-05-17 06:06:55 UTC
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;
}