In an expression of the form
f( g(), h() );
the evaluation order of g()
and h()
is not defined. It is only specify that one must happen before the other. If g()
and h()
both have visible side effects upon which program execution depends, is this undefined behavior?
"Undefined behavior" has a very specific technical meaning: it means that there are literally no restrictions whatsoever on what the program can do. It could set the computer on fire or insult the user. Here, the execution order is unspecified - there are a couple of options of what could happen depending on the order in which things are evaluated. You just can't predict precisely which one it's going to be without knowing more about the compiler, the optimizer, and the execution environment.