mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
51acb01f73
When calling `g_set_object()` for a type derived from `GObject`, GCC 9.2 was giving the following strict aliasing warning: ``` ../../source/malcontent/libmalcontent-ui/user-controls.c:1001:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 1001 | if (g_set_object (&self->user, user)) /opt/gnome/install/include/glib-2.0/gobject/gobject.h:744:33: note: in definition of macro ‘g_set_object’ 744 | (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \ | ^~~~~~~~~~ ``` This was due to the `(GObject **)` cast. Pass the pointer through a union to squash this warning. We already do some size and type checks of the dereferenced type, which should catch casual errors. The `g_object_ref()` and `g_object_unref()` calls which subsequently happen inside the `g_set_object()` function also do some dynamic type checks. Add a test. Signed-off-by: Philip Withnall <withnall@endlessm.com> |
||
---|---|---|
.. | ||
.gitignore | ||
autoptr.c | ||
binding.c | ||
boxed.c | ||
closure-refcount.c | ||
closure.c | ||
dynamictests.c | ||
enums.c | ||
flags.c | ||
genmarshal.py | ||
ifaceproperties.c | ||
marshalers.list | ||
meson.build | ||
mkenums.py | ||
object.c | ||
param.c | ||
private.c | ||
properties.c | ||
qdata.c | ||
reference.c | ||
signal-handler.c | ||
signals.c | ||
taptestrunner.py | ||
testcommon.h | ||
testing.c | ||
threadtests.c | ||
type.c | ||
value.c |