a question about const and pure functions.

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Thu Nov 11 15:09:00 GMT 2004


    A "const" call has no side-effects and its results depend purely on the
    values of its arguments.  This closely follows the mathematical notion
    of a "function".  A "pure" call has no side-effects, but in addition to
    it's arguments may depend upon the memory/global variables of the system.

"The devil is in the details", as they say!  Is memoization considered
a "side-effect", for example?  What about a function passed a pointer and
which indirectly modifies that point?  Is that a "side-effect"?  It's
very tricky to get definitions exactly right.



More information about the Gcc mailing list