The reason others have already indicated that the order in which functional parameters are evaluated is unspecified behavior, and therefore should not be relied upon. But there is another, possibly serious problem:
The read_mat function can access static resources, such as static / global variables, and then return their values. Like this:
static int x; int inc (void) { x++; return x; } printf("%d %d", inc(), inc());
The actual result of the function will depend on the evaluation order.
(This snippet is taken from an interview test that I use when hiring C programmers. I ask what the output of this code is and the correct answer is β2 1β or β1 2β. The question checks if the C programmer knows the concepts are static initialization and evaluation procedure.)
source share