This is the mail archive of the
libstdc++@gcc.gnu.org
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
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Abe <abe149 at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 10 Dec 2012 00:47:27 +0000
- Subject: Re: room for improvement in implementation of "std::advance(InputIterator)": make it more resilient to bugs in user-level code: in particular, negative distances
- References: <CA+Xw_vCXGQ-Abq6kNKi47tYnXw7gL7ay+K3_ZtqNK5-DQBUNEw@mail.gmail.com>
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.