function attributes

While extending the documentation of the gcc function attribute macros,
I found that many of the functions in glib which are marked as G_GNUC_CONST
are not actually const functions according to the definition found in the
GNU C manual
(, since they are
derefencing pointer arguments or read global memory. These functions should
probably be
declared pure instead of const.

g_unichar_*, g_ascii_*, g_spaced_primes_closest, g_quark_to_string (these
access global memory)
g_int_equal (dereferences pointer arguments)

Furthermore, _glib_gettext could be marked as G_GNUC_FORMAT(1) and
g_malloc and friends and a lot of the functions returning newly-allocated
strings could
be marked G_GNUC_MALLOC after defining G_GNUC_MALLOC to be

I have put this in bugzilla as #61780.


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