https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109914
--- Comment #6 from Paul Eggert <eggert at cs dot ucla.edu> --- (In reply to Jan Hubicka from comment #5) > yes, however both const and pure attributes allows compiler to also > remove the call if return value is unused. So here finiteness matters. Thanks for mentioning that. I now see that there are other differences between const/pure and unsequenced/reproducible: see N2956 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm#gcc>, which says that the GCC notions are stricter than the corresponding C23 notions. N2956 doesn't mention finiteness as one of the strictness differences, though, I guess because the C23 standardizers didn't notice that part of the GCC documentation. So my idea that "[[reproducible]] and __attribute__((pure)) are supposed to be the same thing" is incorrect. Similarly, [[unsequenced]] and __attribute__((const) are not the same thing. Oh well. We may need to change Gnulib because of these discrepancies. >> I agree with Bruno's main point that none of this stuff should matter for >> static functions. --suggest-attribute=* warnings are useless chatter for >> static functions. > It helps the compiler to solve the halting problem. This isn't a halting-problem situation. If GCC cannot deduce that a static function halts, and if no calls to that function discard the return value (so the optimization you mentioned can't apply), then suggesting to the developer to add __attribute__((pure)) merely wastes developers' time, and developers either disable the warning or ignore it, neither of which is good. So Bruno's suggestion of suppressing the false positive for his test case still seems to be a good one.