Is this function call valid in C

char* p = init();
p = foo(p);        /* this one */

      

function prototype foo

:

char* foo(char* p);

      

Is it legal to call foo

this way or does it fall into the Undefined Behavior category ?

+3


source to share


2 answers


Yes, it's well defined - there is a sequence point between evaluating function arguments and calling the function.



+9


source


Is foo valid to call this way or does it fall into the Undefined Behavior category?

Yes , order is guaranteed (there is a sequence point between parameter evaluation and function call).




You are probably confusing this with the side effects of unnatural modifications or something else.

+6


source







All Articles