4 ms·
Prior to C++17 such an evaluation order would have violated the standard. ISO/IEC 14882:2011 1.9/13 [Note: Indeterminately sequenced evaluations cannot overlap
by bregma 5y ago
Prior to C++17 such an evaluation order would have violated the standard. ISO/IEC 14882:2011 1.9/13 [Note: Indeterminately sequenced evaluations cannot overlap, but either could be executed first. — end note]. The arguments in a faction call are a comma-separated indeterminate sequence (5.2.2/4 [Note: Such initializations are indeterminately sequenced with respect to each other (1.9) —
end note]).
- ectopod 5y agoIs there any version of C++ in which this interleaving is permitted?
- quietbritishjim 5y agoThe full context to that second quote is: > When a function is called, each parameter ([dcl.fct]) shall be initialized ([dcl.init], [class.copy], [class.ctor]) with its corresponding argument. [ Note: Such initializations are indeterminately sequenced with respect to each other ([intro.execution]) — end note ] So it's only about initialisation of parameters from arguments, not to the evaluation of arguments. (For example if foo() takes a std::string parameter, and bar() returns a const char*, then in the expression foo(bar()) the above quote refers to the call to the string constructor, not to the call to bar().) The more relevant part is 5.2.2/8: > [ Note: The evaluations of the postfix expression and of the argument expressions are all unsequenced relative to one another. All side effects of argument expression evaluations are sequenced before the function is entered (see [intro.execution]). — end note ]
- MaxBarraclough 5y ago> Prior to C++17 such an evaluation order would have violated the standard Herb Sutter disagrees. [0] The C++ legalese you've quoted seems decisive, unfortunately Sutter's post doesn't mention it. See also [1][2]. edit quietbritishjim beat me to it, and with a better informed comment to boot. [0] https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/ https://herbsutter.com/2013/05/29/gotw-89-solution-smart-poi... (ctrl-f for known, and see also the comment thread at the bottom of the page) [1] https://stackoverflow.com/a/48844115/ https://stackoverflow.com/a/48844115/ [2] https://stackoverflow.com/a/46472497/ https://stackoverflow.com/a/46472497/