Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] crash on iterator copy or assignment
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-03-12 16:38:41


On Thu, Mar 12, 2009 at 1:50 PM, Dominique Devienne <ddevienne_at_[hidden]> wrote:
> // public method
> std::auto_ptr<FooIterator> iterate(const MyTypeInfo& tinfo) {
>   FoosByType& by_type = get<ByType>(foo_index_);

>   std::auto_ptr<ByTypeFooIterator > iter_ptr = new ByTypeFooIterator;

A colleague found the culprit above, thanks to a GCC warning on the above line.

Using the "construction" assignment, which I assumed would call the
auto_ptr(T*) Ctor,
was in fact calling auto_ptr_ref(void*) and then auto_ptr(auto_ptr_ref&),
leading to the crash in tie on the next line. (there must be a bug in
vs2005 std lib here...)

Changing this to iter_ptr(new ByTypeFooIterator); forced the use of
auto_ptr(T*) and
the whole unit test worked like a charm ;-)

>   boost::tie(iter_ptr->cur_, iter_ptr->end_) = by_type.equal_range(tinfo);
>   return iter_ptr;
> }

Note that I could then do my "interleaving" test, and this also worked
the first time.

Boost Multi-Index is simply a gem! Thanks so much for it. Cheers, --DD


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net