GNOME Bugzilla – Bug 140346
libmoduletestplugin_a.c gives type-punned warning when compiling glibc-2.2.3
Last modified: 2011-02-18 16:14:20 UTC
I'm getting a type-punning warning from gcc when it processes the file libmoduletestplugin_a.c and gets to the function gplugin_a_module_func Exact warning is: libmoduletestplugin_a.c: In function `gplugin_a_module_func': libmoduletestplugin_a.c:64: warning: dereferencing type-punned pointer will break strict-aliasing rules This is cleared up if I change the function to the following: G_MODULE_EXPORT void gplugin_a_module_func (GModule *module) { gpointer (*f) (void) = NULL; if (!g_module_symbol (module, "gplugin_say_boo_func", (gpointer *)f)) { g_print ("error: %s\n", g_module_error ()); exit (1); } f (); } It *was*: G_MODULE_EXPORT void gplugin_a_module_func (GModule *module) { void (*f) (void) = NULL; if (!g_module_symbol (module, "gplugin_say_boo_func", (gpointer *) &f)) { g_print ("error: %s\n", g_module_error ()); exit (1); } f (); } If I may ask: was there a reason to use void (*f) instead of gpointer (*f)? Am I missing something here?
Created attachment 26751 [details] [review] Proposed patch
*** Bug 140482 has been marked as a duplicate of this bug. ***
Created attachment 26957 [details] [review] Proposed patch Oops... last patch was the wrong way around. Thanks to gazbo of HuSi for point this out!
Comment on attachment 26751 [details] [review] Proposed patch Diff was the wrong way around. Oops.
Already fixed in cvs