LibreOffice, about avoiding "attempt to erase from container with a past-the-end iterator"
Stephan Bergmann
sbergman at redhat.com
Wed May 28 08:01:51 PDT 2014
On 05/28/2014 02:01 PM, julien2412 wrote:
> I noticed this interesting change
> http://cgit.freedesktop.org/libreoffice/core/commit/?id=72827968e606adcdf8c16e5381b887180975ae46
> ("Try to avoid "attempt to erase from container with a past-the-end
> iterator")
> I tried to search similar cases in Opengrok and found some of them (because
> quite often a same mistake is made several times)
>
> See
> http://opengrok.libreoffice.org/search?q=%22erase%28+std%3A%3Afind%22&project=core&defs=&refs=&path=&hist=
>
> Should we apply the fix for all of them or it's not so automatic because in
> some cases we're 100% sure "find" function retrieves a dereferenceable
> iterator?
In each individual case, the question needs to be what the actual fix
should be: Either it is guaranteed that the sequence contains the
element, in which case the "fix" is to add an "assert" (and some /other/
code apparently needs to be fixed if that assert ever is violated). Or
the sequence need not contain the element, in which case the fix is to
add an "if" (as in the commit referenced above). This can only be
decided by careful inspection of the code (which has presumably /not/
been done in the case of the above commit).
Stephan
More information about the LibreOffice
mailing list