Macro to suppress 'dereferencing type-punned pointer...' when using weak refs
Submitted by Chris Wilson
Link to original bug (#344552)
Description
GCC unhelpfully warns about casting to a gpointer * when using g_object_add_weak_pointer and friends. That warning can be suppressed by performing the cast via a char *.
My suggestion would be to add:
#define G_WEAK_LOCATION(ptr) ((gpointer *)(char *)(ptr))
to gobject.h which then reads like [example from gtkfilechooserbutton.c]: g_object_add_weak_pointer (G_OBJECT (priv->dialog), G_WEAK_LOCATION (&priv->dialog));
Compared to the original: g_object_add_weak_pointer (G_OBJECT (priv->dialog), (gpointer *) (&priv->dialog));
Version: 2.11.x