https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83503

--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #9)

This is not a style warning.  Because there is no valid use case for having
both attribute const and pure on two declarations of the same function, in the
absence of access to its definition there also is no one correct choice to make
as to which one to honor and which one to ignore.  Honoring const when the
definition is, in fact, pure, is a bug.  Honoring pure when the definition is
const results in less than optimal code.

In cases where there is no one correct/safe/optimal choice the best response is
to point out the conflict/ambiguity and let the user resolve it based on the
definition of the function.

The difference the patch introduces is that rather than always honoring const
as before, GCC 8 honors the attribute on the first declaration.  (My preference
would have been to honor pure to be on the safe side but I didn't think there
would have been sufficient support for the change and, with a warning, it also
didn't seem like as big a risk anymore, while a consistent treatment of all
conflicts seems like a more important goal).

But this bug is not the right place to discuss the merits of the warning itself
or the handling of conflicts.

Reply via email to