<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 12, 2014 at 10:32 AM, Arthur O'Dwyer <span dir="ltr"><<a href="mailto:arthur.j.odwyer@gmail.com" target="_blank">arthur.j.odwyer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Wed, Mar 12, 2014 at 10:17 AM, Jonathan 'Rynn' Sauer<br>
<<a href="mailto:jonathan.sauer@gmx.de">jonathan.sauer@gmx.de</a>> wrote:<br>
> Hello,<br>
><br>
>> +      Args->data(), Args->data() + Args->size(), Diags,<br>
><br>
> Isn't that identical to<br>
><br>
>   &*Args->begin(), &*Args->end()<br>
<br>
</div>The old code's organization implied that if Args is empty, then any<br>
variation on &Args[0], *Args->begin(), etc. has undefined behavior.<br>
Certainly *Args->begin() does not identify an object. I don't know<br>
enough C++ to tell you whether &*Args->begin() is necessarily legal or<br>
not.</blockquote><div><br></div><div>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.</div>
</div></div></div>