#include <iostream>
#include<boost/asio.hpp>
int main (int argc, char * const argv[])
{
boost::asio::io_service io_service;
boost::asio::ip::tcp::acceptor acceptor(io_service);
std::cout<<"acceptor instantiated."<<std::endl;
return 0;
}
[Session started at 2009-07-28 16:00:10 +0800.]
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h:127:
error: attempt to copy-construct an iterator from a singular iterator.
Objects involved in the operation:
iterator "this" @ 0x0x100480 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator);
state = singular;
}
iterator "other" @ 0x0xbffff364 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator);
state = singular;
}
[Session started at 2009-07-28 16:00:10 +0800.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 3497.
The Debugger Debugger is attaching to process
> 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 mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users