|
Boost Users : |
Subject: Re: [Boost-users] [newbie] Boost 1.39 in Mac XCode get "error: attempt to copy-construct an iterator from a singular iterator."
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-07-28 09:08:39
On 28 Jul 2009, at 09:10, Victor Tsang wrote:
> Hi,
> ...
>
> The Debugger Debugger is attaching to process
>
> It generates a runtime error "error: attempt to copy-construct an
> iterator
> from a singular iterator.".
>
>
> However, if I compile the code in terminal:
> g++ -o test -g -Wall main.cpp -lboost_system-xgcc40-mt
>
> It runs okay without any runtime error.
>
To duplicate the error from the command line, add ' -D_GLIBCXX_DEBUG '
to the command line, which turns on g++'s iterator debugging. Doing
this, I can duplicate your problem.
The problem can be boiled down to the following, illegal, code.
#include <vector>
#include <list>
int main(void)
{
std::vector<std::list<int>::iterator> v;
v.resize(1);
}
The code can be fixed (although there may be other occurrences of
similar problems) by changing around line 220 on asio/detail/
hash_map.hpp from:
// Update number of buckets and initialise all buckets to empty.
buckets_.resize(num_buckets);
for (std::size_t i = 0; i < buckets_.size(); ++i)
buckets_[i].first = buckets_[i].last = end;
to:
// Update number of buckets and initialise all buckets to empty.
bucket_type bucket;
bucket.first = bucket.last = end;
buckets_.resize(num_buckets, bucket);
I'm surprised boost isn't tested with iterator checking. Any
particular reason, or has simply no-one tried?
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