Hi Paul,
I did this:
> (gl_tree_iterator_free): Mark as 'const'.
and now GCC gives me this warning:
In file included from gl_avltree_oset.c:46:
gl_anytree_oset.h:442:1: warning: 'const' attribute on function returning
'void' [-Wattributes]
for
static void _GL_ATTRIBUTE_CONST
gl_tree_iterator_free (gl_oset_iterator_t *iterator
_GL_ATTRIBUTE_MAYBE_UNUSED)
{
}
The description you added in attribute.h:
/* It is OK for a compiler to omit duplicate calls with the same arguments.
This attribute is safe for a function that neither depends on
nor affects observable state, and always returns exactly once -
e.g., does not loop forever, and does not call longjmp.
(This attribute is stricter than ATTRIBUTE_PURE.) */
/* Applies to: functions. */
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
makes perfect sense for a function that returns void. However, in view of the
GCC documentation [1] the GCC warning basically means "the 'const' attribute
here does not help me in doing common-subexpression elimination, since the
return type is 'void'".
To me, this is a pointless warning. Would you agree that a bug report to
the GCC people makes sense?
Bruno
[1]
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Common-Function-Attributes.html