Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-07-08 14:16:38


From: "David B. Held" <dheld_at_[hidden]>
> 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_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk