4 ms·
GCC has a 'pure' attribute. I don't know if it's only used for optimization, but it also serves as a kind of comment for whoever looks at the function in the fu
by el_presidente 14y ago
GCC has a 'pure' attribute. I don't know if it's only used for optimization, but it also serves as a kind of comment for whoever looks at the function in the future.
- copx 14y ago"pure" and "const" are GCC function attributes which are supposed to help the optimizer. Confusingly enough "const" demands a higher level of purity than "pure".. I would never use those attributes except - maybe - in the most critical loops and then only with a big "WARNING!!!" sign. Why? GCC does not / cannot enforce the guarantees given by "const" and "pure" yet the optimizer always assumes they are true. I.e. accidentally reduce the purity of a function decorated in this way.. and you might create very hard to find bugs. This is a general problem in C and C++, those languages simply weren't designed to enforce such contracts. C99's "restrict" has the same problem.