On Wed, Mar 12, 2014 at 10:32 AM, Arthur O'Dwyer
<[email protected]>wrote:

> On Wed, Mar 12, 2014 at 10:17 AM, Jonathan 'Rynn' Sauer
> <[email protected]> wrote:
> > Hello,
> >
> >> +      Args->data(), Args->data() + Args->size(), Diags,
> >
> > Isn't that identical to
> >
> >   &*Args->begin(), &*Args->end()
>
> The old code's organization implied that if Args is empty, then any
> variation on &Args[0], *Args->begin(), etc. has undefined behavior.
> Certainly *Args->begin() does not identify an object. I don't know
> enough C++ to tell you whether &*Args->begin() is necessarily legal or
> not.


It's not. If *Args is empty, then *Args->begin() is applying * to a
non-dereferenceable iterator, which has undefined behavior. *Args->end()
has undefined behavior no matter whether *Args is empty. data() was added
to vector in C++11 to support exactly this sort of thing.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to