tOn Mon, Jan 04, 2021 at 01:42:48PM +0100, Theo Buehler wrote:

> > > +         return log_sockaddr(addr2sa(addr, 0, &len), len);
> > 
> > Perhaps I haven't yet had enough coffee this year, but I'm unsure
> > whether it is actually guaranteed that addr2sa() is called before the
> > second len in this line is passed to log_sockaddr().
> 
> Answering my own question: C99 and C11 6.5.2.2.12 require that all side
> effects must be completed before log_sockaddr() is called. As addr2sa()
> changes the second len as a side effect, this should be fine.
> 
> ok tb
> 

I am not convinced. Consider

#include <stdio.h>

char x;

char f(char *p)
{
        *p = 'f';
        return 'r';
}

int main()
{
        x = 'm';
        printf("%c %c %c\n", x, f(&x), x);
}

prints "m r f" here. The first x is not influenced by the call to
f(), while the second is. So the side effetc only affects one of the args.

        -Otto


Reply via email to