Earlier quoted context omitted.
I'm not a big fan of UB either, but keeping the order of argument evaluation indeterminate seems very sensible to me. Imagine you have a function like f(int, double). If argument evaluation order is fixed, you can no longer exchange the order of arguments: for all you know, someone might be depending on the first argument being evaluated first!
If there's really a performance advantage to argument reordering then you can do it whenever there are less than two arguments that may have side effects. Safe instances would be: * constants * regular variables that aren't using the cast constructor for implicit conversion * member functions marked const * constexpr functions You would only need to actually evaluate function calls that may change global state, or th…
* There's a function f(int, double), called in ~100 places, written by many different people.
* For some reason I decide to change it to f(double, int). Consistency, or preparing for some other refactoring, whatever.
* I have to track down ~100 occurrences of f and exchange arguments. Time-consuming but no big deal.
* If any code was dependent upon compiler silently evaluating the arguments in a particular way, then the code was broken, and reasonably competent coders don't write too much broken code. (Moreover, such a dependency is 99% likely to be broken by random changes in codes or compiler options, so chances are that I wouldn't encounter too many such bugs.)
In your world, it is just about impossible. If I want to go ahead, I could either change every occurrence into:
int arg1 = ...;
double arg2 = ...;
f(arg2, arg1);
...or pore through every line calling f to see if it's safe.C++ already has a reputation of being a difficult language to refactor, and your proposal will make it about impossible.