https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109914
--- Comment #3 from Bruno Haible <bruno at clisp dot org> --- (In reply to Jan Hubicka from comment #2) > The reason why gcc warns is that it is unable to prove that the function is > always finite. This means that it can not auto-detect pure attribute since > optimizing the call out may turn infinite program to finite one. > So adding the attribute would still help compiler to know that the loops are > indeed finite. Thanks for explaining. So, the warning asks the developer not only to add an __attribute__((__pure__)) marker, but also to verify that the function terminates. In this case, it does, but it took me a minute of reflection to convince myself. For what purpose shall the developer make this effort? The documentation https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Common-Function-Attributes.html says that it's to allow the compiler to do common subexpression elimination. But in this case, the compiler could easily find out that it cannot do common subexpression elimination anyway, because: - The only caller of this function (have_xattr) is file_has_acl. - In this function, there are three calls to have_xattr. - Each of them is executed only at most once. Control flow analysis shows this. - Each of them has different argument lists: The first argument is a string literal in each case, namely "system.nfs4_acl", "system.posix_acl_access", "system.posix_acl_default" respectively. So, there is no possibility for common subexpression elimination here, even if the function was marked "pure". Therefore it is pointless to suggest to the developer that it would be a gain to mark the function as "pure" and that it is worth spending brain cycles on that.