Re: type-punning warnings with optimizations turned on?



On 7/6/07, jcupitt gmail com <jcupitt gmail com> wrote:
On 7/6/07, Alan M. Evans <gtkappdevellist alanevans org> wrote:
> That's interesting. Unfortunately for me, I don't have a lot of casting
> options. Really, in this case:

I meant that whatever it is that g_static_mutex_*() is doing, it might
be doing a cast like this internally. Therefore you may have found a
(probably rather minor) GLib bug.

I've found the cast that it's complaining about. It's part of the
gthread configure: on my system it's in
/usr/lib/glib-2.0/include/glibconfig.h:

#define g_static_mutex_get_mutex(mutex) \
 (g_thread_use_default_impl ? ((GMutex*) ((mutex)->static_mutex.pad)) : \
  g_static_mutex_get_mutex_impl_shortcut (&((mutex)->runtime_mutex)))

The culprit is

 (GMutex*) ((mutex)->static_mutex.pad)

Change this to:

 (GMutex*) ((void *) ((mutex)->static_mutex.pad))

ie. cast via void*, and the warnings vanish.

I don't know whether this is the correct fix, of course. And it only
shows up with -O on x86-64, so probably no one cares.

Of course this isn't the correct place to patch either: we'd need to
track down the thing that makes this line in glib configure.

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]