
From: "David B. Held" <dheld@codelogicconsulting.com>
Rob Stewart wrote:
[...] Thus, any expression using commas must be understood to have indeterminant order of evaluation.
Are you sure?
No, I was wrong. The built-in semantics are well-defined for some uses.
Consider:
int v[] = { foo(), bar() };
Doesn't this exhibit the same problem? If so, the problem is only that an initialization library exposes the problem to more daylight.
This doesn't exhibit the same behavior because of 1.9/18, contrary to my questioning above.
But consider:
int v = foo(), bar();
I agree that expecting more order-of-initialization than you get is a problem, but the funny thing is that the comma operator gives you more than other uses of the comma.
Yes, overloading operator, eliminates the built-in comma's "internal" sequence point, so it can be surprising. This, of course, is Andrei's original point. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;