|
Boost : |
Subject: Re: [boost] [1.37.0][serialization] Assertion failed at libs/serialization/src/extended_type_info.cpp:92
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2008-10-21 10:41:16
> Hartmut Kaiser escribió:
> >> assert(start != end);
> >>
> >> // remove entry in map which corresponds to this type
> >> do{
> >> if(this == *start)
> >> x.erase(start++);
> >> else
> >> ++start;
> >> }while(start != end);
> >>
> >
> > After looking at this code again I have the impression that it is
> broken
> > anyways. You can't safely increment an iterator after deleting the
> object it
> > points to: erase(start++).
>
> I think your objection is wrong: erase(start++) is perfectly safe
> because the incrementing op
> is executed before erase is invoked.
Actually, to be concise, you're invoking undefined behavior. The Standard
doesn't guarantee any execution order of operations in this context. The
only thing which is guaranteed is, that the operation executed by erase()
uses the initial value and afterwards start has been incremented (well,
whatever happens if you increment an iterator after erasing the element it's
pointing to).
Regards Hartmut
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk