Order of evaluation and associativity are two different things, take the example:
int x = func1() - func2() - func3(); //having int return types
In this expression you can't know if func1()
will be evaluated first or last, meaning, you don't know which function will be called and return its value first, however you know that the associativity, as with +
, will be left-to-right, first func1() - func2()
then the result of that subtraction - func3()
.
There is no concept of left-to-right or right-to-left evaluation in C, which is not to be confused with left-to-right and right-to-left associativity of operators: the expression f1() + f2() + f3()
is parsed as (f1() + f2()) + f3()
due to left-to-right associativity of operator+
, but the function call to f3()
may be evaluated first, last, or between f1()
or f2()
at run time.
https://en.cppreference.com/w/c/language/eval_order