glib/gobject/tests
Philip Withnall 51acb01f73 gobject: Fix strict aliasing warnings with g_set_object()
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>
2020-02-18 12:15:52 +00:00
..
.gitignore .gitignore updates 2015-10-23 11:28:03 -04:00
autoptr.c gtype: Define auto-cleanup functions for Module class 2019-12-13 20:07:51 +01:00
binding.c binding: Use g_assert_*() in binding tests rather than g_assert() 2019-11-15 11:06:14 +00:00
boxed.c boxed: Fix double free in boxed unit tests 2013-11-11 07:20:09 +01:00
closure-refcount.c tests: Fix closure-refcount to preserve old semantics 2019-02-28 07:05:29 +01:00
closure.c Fix the closure test in continuous 2014-05-30 10:22:35 -04:00
dynamictests.c Drop trailing semi-colon from G_DEFINE_ macro 2017-04-10 10:38:31 +01:00
enums.c gobject: Add to_string() functions for Enum and Flags types 2017-03-30 09:52:28 +01:00
flags.c Add unit test for flags validation 2018-11-01 01:41:32 +03:00
genmarshal.py Merge branch '1792-again-marshal-params' into 'master' 2019-07-29 11:45:07 +00:00
ifaceproperties.c gobject/tests/: LGPLv2+ -> LGPLv2.1+ 2017-05-24 11:58:19 +02:00
marshalers.list Add more tests for signal emissions 2012-03-02 17:13:04 +01:00
meson.build tests: Add a test for g_assert_finalize_object() 2019-10-18 15:55:27 +01:00
mkenums.py GObject: Fix mkenums.py and genmarshal.py tests on Windows 2019-06-25 00:04:48 +08:00
object.c gobject: re-allow finalization from constructor() 2014-02-15 10:20:53 -05:00
param.c gparam: Tighten up property name validation 2019-11-15 11:06:14 +00:00
private.c Annotate various types and macros as deprecated 2019-05-30 10:39:11 +01:00
properties.c Allow calling get_property() with an uninitialized GValue 2019-06-04 20:05:24 +01:00
qdata.c gobject/tests/: LGPLv2+ -> LGPLv2.1+ 2017-05-24 11:58:19 +02:00
reference.c gobject: Fix strict aliasing warnings with g_set_object() 2020-02-18 12:15:52 +00:00
signal-handler.c Add a performance test for signal connection 2015-05-27 14:41:19 -04:00
signals.c gsignal: Warn if g_signal_lookup() is called on an invalid signal name 2019-11-15 11:06:14 +00:00
taptestrunner.py tests: Avoid writing ever increasing sequence of null bytes to test logs 2018-12-12 12:57:51 +01:00
testcommon.h gobject/tests/: LGPLv2+ -> LGPLv2.1+ 2017-05-24 11:58:19 +02:00
testing.c tests: Add a test for g_assert_finalize_object() 2019-10-18 15:55:27 +01:00
threadtests.c g_usleep: round up the next millisecond on Windows. See #1371 2018-05-27 09:23:25 +02:00
type.c tests: Remove unneeded ";" in G_DEFINE_INTERFACE_WITH_CODE 2019-07-29 17:28:01 +02:00
value.c Allow passing unset GValues to g_value_unset() 2015-10-02 10:07:53 -04:00