docs: Update the documentation for G_GNUC_MALLOC to reflect recent GCC
commitc879f50f8a60be17dfa2d2a2b0c48b15c2f62445
authorPhilip Withnall <withnall@endlessm.com>
Wed, 22 Aug 2018 10:05:30 +0000 (22 11:05 +0100)
committerPhilip Withnall <withnall@endlessm.com>
Wed, 22 Aug 2018 10:18:02 +0000 (22 11:18 +0100)
tree30313180242fe7be779b63f11994be386ee533a8
parentb2029fa9c7a1a3ac555e989b80c432963c1de0fc
docs: Update the documentation for G_GNUC_MALLOC to reflect recent GCC

Thanks to some great investigation by Benjamin Moody, it’s clear that
our documentation and usage of G_GNUC_MALLOC has fallen behind GCC’s
interpretation of the malloc attribute, meaning that recent versions of
GCC could miscompile code which uses G_GNUC_MALLOC incorrectly.

Update the documentation of G_GNUC_MALLOC to match the current GCC
documentation (for GCC 8.2). Following commits will drop our use of
G_GNUC_MALLOC from inappropriate functions.

Specifically, the change in GCC’s interpretation of the malloc attribute
which could cause miscompilation is that returned storage areas are now
assumed to not contain valid pointers — so realloc() cannot have the
malloc attribute, and neither can a function which returns a newly
allocated structure with fields initialised to other pointers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://gitlab.gnome.org/GNOME/glib/issues/1465
glib/docs.c