3 ms·
Wasn't the ordering thing in C for stack push order in calling conventions? At least that's one theory I've heard.
by eddyb 8y ago
Wasn't the ordering thing in C for stack push order in calling conventions? At least that's one theory I've heard.
- kazinator 8y agoUnspecified evaluation order helps dumb compilers produce better code. Whenever a particular evaluation order is convenient in order fit some canned code generation pattern, like a function call or whatever, that desired evaluation order can just be blindly used, rather than following forced evaluation order (using temporaries to hold the results). Compilers for languages with strict evaluation order can still perturb evaluation order when it is safe to do so: like when expressions do not have side effects, or have effects that don't mutually interfere and are not external. They can thus avoid or eliminate the temporaries. C is still being specified like it's 1982 and compilers have to run in a few kilobytes of RAM, in a single pass, and go straight from source to target machine code.