Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Mon, Aug 6, 2012 at 11:21 AM, Stephan Bergmann <sbergman@redhat.com> wrote:
On 08/06/2012 04:08 PM, Kohei Yoshida wrote:

Regarding

         iterator itr = begin();
         while(itr != end())
         {
             if(itr->GetRange().empty())
                 maConditionalFormats.erase(itr++);
             else
                 ++itr;
         }

that erase line causes an undefined behavior, and subtle, hard-to-find
bug later.  maConditionalFormats is a boost::ptr_set which uses
std::set in its implementation.  The std::set's erase call invalidates
the iterator of the element that has just been deleted, and that line
increments the iterator after it's been invalidated.


No, the line first increments itr, then calls erase (on the old itr value).

Ok then.  I have no problem with it.

Kohei

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.