This is the mail archive of the
mailing list for the GCC project.
Re: [tree-ssa] Fix gcc.dg/tree-ssa/20030530-2.c
- From: Michael Matz <matz at suse dot de>
- To: Jason Merrill <jason at redhat dot com>
- Cc: law at redhat dot com, Diego Novillo <dnovillo at redhat dot com>,"gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 11 Jun 2003 17:54:57 +0200 (CEST)
- Subject: Re: [tree-ssa] Fix gcc.dg/tree-ssa/20030530-2.c
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;
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 ;-)