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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Evaluation order of operands
- Why C treats array parameters as pointers?
- Do not use sizeof for array parameters
- 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
- How to call function within function in C or C++
- Write a one line C function to round floating point numbers
- Does C support function overloading?
- How can I return multiple values from a function?
- What is the purpose of a function prototype?
- How to declare a pointer to a function?
- C function to Swap strings
- Can we call an undeclared function in C++?
- Can we use function on left side of an expression in C and C++?
- Function Pointer in C
- Importance of function prototype in C
- What happens when a function is called before its declaration in C?
- Default arguments and virtual function

