Search code examples
cfunctionundefined-behavior

Is this kind of function calls permissible in C


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

the function foo prototype:

char* foo(char* p);

Is it permissible to call foo that way, or does it fall in the Undefined Behavior category?


Solution

  • Yes, this is well-defined - there is a sequence point between the evaluation of the function arguments and the function call.