What is evaluation order of function parameters in C?
It is compiler dependent in C. It is never safe to depend on the order of evaluation of side effects. For example, a function call like below may very well behave differently from one compiler to another:
void func (int, int); int i = 2; func (i++, i++); |
chevron_right
filter_none
There is no guarantee (in either the C or the C++ standard language definitions) that the increments will be evaluated in any particular order. Either increment might happen first. func might get the arguments `2, 3′, or it might get `3, 2′, or even `2, 2′.
Source: http://gcc.gnu.org/onlinedocs/gcc/Non_002dbugs.html
Recommended Posts:
- Evaluation order of operands
- Do not use sizeof for array parameters
- Why C treats array parameters as pointers?
- Order of operands for logical operators
- Sorting 2D Vector in C++ | Set 2 (In descending order by row and column)
- Sorting Vector of Pairs in C++ | Set 2 (Sort in descending order by first and second)
- Program to copy the contents of one array into another in the reverse order
- arc function in C
- strcmpi() function in C
- iswctype() function in C/C++
- strtoimax() function in C++
- wctype() function in C/C++
- strtoumax() function in C++
- iswxdigit() function in C/C++
- strrev() function in C



