This is the mail archive of the gcc-patches@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]

Re: [tree-ssa] Fix gcc.dg/tree-ssa/20030530-2.c


Hi,

On Wed, 11 Jun 2003, Jason Merrill wrote:

> Incidentally, I note that the documentation says that a pure function can
> refer to global variables.  I think this is bogus; the distinction between
> const and pure should be that a pure function can load from the memory
> pointed to by its arguments, whereas a const function must not.

I don't think so.  A pure function just depends on the current state
(which includes global memory), but doesn't affect it, except returning a
value which then is only included into state by an assignment or similar.
A const function in addition depends _predictably_ on the state, namely
when presented with the same arguments gives the same result.

But as said, the state includes global memory.  I want to be able to mark:

static int bla;
int get_counter()
{
  return bla;
}

as pure even though it read memory.

> If a pure function can load from arbitrary memory, that means that we
> can't optimize calls to strlen across a write to global memory.

Well, yes so be it.  We could invent another attribute ;-)


Ciao,
Michael.


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