This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: pure string functions
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: pure string functions
- From: Andi Kleen <ak at suse dot de>
- Date: 11 May 2000 15:11:12 +0200
- Cc: libc-alpha at sourceware dot cygnus dot com
- References: <hon1lxwkp5.fsf@maclaurin.suse.de>
Andreas Jaeger <aj@suse.de> writes:
>
> Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
> Interesting non-pure functions are functions with infinite loops or those
> depending on volatile memory or other system resource, that may change between
> two consetuctive calls (such as @code{feof} in multithreding environment).
So you are sure gcc correctly handles things like this in all cases with
pure strlen:
func()
{
char bla[10] = "blub";
int a,b;
a = strlen(bla);
// do something with a
func2(bla);
b = strlen(bla);
// do something with b
}
func2(char *bla)
{
bla[1] = 0;
}
?
My understanding of pure functions was always that they are only
allowed to depend on argument values, but not on values pointers
point to.
-Andi