This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


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

Re: pure string functions


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


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