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 140346 - libmoduletestplugin_a.c gives type-punned warning when compiling glibc-2.2.3
libmoduletestplugin_a.c gives type-punned warning when compiling glibc-2.2.3
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gmodule
2.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 140482 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-04-17 16:05 UTC by Chris Sherlock
Modified: 2011-02-18 16:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (498 bytes, patch)
2004-04-17 16:06 UTC, Chris Sherlock
none Details | Review
Proposed patch (529 bytes, patch)
2004-04-22 12:20 UTC, Chris Sherlock
none Details | Review

Description Chris Sherlock 2004-04-17 16:05:44 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?
Comment 1 Chris Sherlock 2004-04-17 16:06:24 UTC
Created attachment 26751 [details] [review]
Proposed patch
Comment 2 Owen Taylor 2004-04-21 19:03:12 UTC
*** Bug 140482 has been marked as a duplicate of this bug. ***
Comment 3 Chris Sherlock 2004-04-22 12:20:39 UTC
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 4 Chris Sherlock 2004-04-22 12:21:38 UTC
Comment on attachment 26751 [details] [review]
Proposed patch

Diff was the wrong way around. Oops.
Comment 5 Matthias Clasen 2005-01-13 18:23:16 UTC
Already fixed in cvs