This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: a question about const and pure functions.
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: roger at eyesopen dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 11 Nov 04 10:12:13 EST
- Subject: Re: a question about const and pure functions.
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.