Hi,

I'm new to boost. It seems that the coding of boost library is not very clean as it makes the debug code aborted by generating a runtime error like this: "error: attempt to copy-construct an iterator from a singular iterator.".

Here are the steps to reproduce the fault:

I downloaded the source and install the things to /usr/local/include as well as /usr/local/lib.

I test the code by creating a "C++ Tool" project in XCode.

1. Create a new C++ Tool project.
2. Add the header search path /usr/local/include/boost-1_39 and library search path /usr/local/lib into the project.
3. Add "Other Linker Flags" "-lboost_system-xgcc40-mt" in the project setting.
4. Edit the main.cpp as below:

#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;

}


5. Build and run. Check out the result from the Console window as captured below:


[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


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.



Regards,

Victor Tsang