pure string functions
Andi Kleen
ak@suse.de
Thu May 11 05:11:00 GMT 2000
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
More information about the Libc-alpha
mailing list