This is the mail archive of the
mailing list for the libstdc++ project.
Re: room for improvement in implementation of "std::advance(InputIterator)": make it more resilient to bugs in user-level code: in particular, negative distances
On Sun, Dec 9, 2012 at 6:47 PM, Jonathan Wakely <email@example.com> wrote:
> On 10 December 2012 00:11, Abe wrote:
>> Since the extra check would incur a tiny amount of run-time overhead,
>> maybe the check itself should be surrounded by "#if !NDEBUG" or
>> similar, but perhaps a modified version of the above should be put
>> into the "debug/" top-level directory of libstdc++ instead.
> I think checking for negative values only when _GLIBCXX_DEBUG is
> defined would be consistent with checks in the rest of the library.
Agreed. And the check shouldn't silently skip
the loop -- it should issue a diagnostic of some sort
as opposed to pretending it was 0.