This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pure/const function attribute and memoization


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]