room for improvement in implementation of "std::advance(InputIterator)": make it more resilient to bugs in user-level code: in particular, negative distances
Gabriel Dos Reis
gdr@integrable-solutions.net
Mon Dec 10 01:00:00 GMT 2012
On Sun, Dec 9, 2012 at 6:47 PM, Jonathan Wakely <jwakely.gcc@gmail.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.
More information about the Libstdc++
mailing list