This is the mail archive of the gcc@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: [PATCH] Make attribute functions pure


On Sun, 2004-07-25 at 23:32, Robert Dewar wrote:
> You always have to remember that *all* the rules in the
> RM are as-if semantics. So you are allowed any optimization
> which does not affect the semantics. 

The semantics for Pure are not described as "no side effect", but as
permission to omit a call if it meets a precise list of conditions,
and nothing else.

Defined this way, it allows some optimizations and not others, and
in particular it prevents the compiler when it decides to emit a call
from assuming that nothing will change during the call which
is necessary if you want to do memoizing reliably : you can
just pragma Import a side-effect generating procedure and call it within
the Pure function code, and everything will work as expected.

Defined as "no side effect" (assuming this can be described properly)
it will allow other optimizations, and disallow memoizing altogether.

As a programmer I see that as two different semantics, both
useful and none to throw away IMHO that's why I was proposing
a new pragma for the second one (which should match the GNU C
extension).

To be transmitted to the ARG :).

Laurent



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