Back when these attributes were defined, we had no inter-procedural analysis or other fanciness, so I suspect we didn't consider the case where the annotated function only behaved as if it were pure or const. One important case is memoization—a function which uses this technique writes to global memory (so that the computed result can be reused by a future call), but calls to it can be freely scheduled, replicated or removed (for const; for pure, writes to global memory have to be taken into account).

Is it permitted to use pure/const for such functions? What should our documentation say?

--
Florian Weimer / Red Hat Product Security Team

Reply via email to