Hi,<div><br></div><div>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: "<span class="Apple-style-span" style="font-family: Courier; font-size: 12px; font-weight: bold; ">error: attempt to copy-construct an iterator from a singular iterator.</span>".</div> <div><br></div><div>Here are the steps to reproduce the fault:</div><div><br></div><div>I downloaded the source and install the things to /usr/local/include as well as /usr/local/lib.</div><div><br></div><div>I test the code by creating a "C++ Tool" project in XCode.</div> <div><br></div><div>1. Create a new C++ Tool project.</div><div>2. Add the header search path /usr/local/include/boost-1_39 and library search path /usr/local/lib into the project.</div><div>3. Add "Other Linker Flags" "-lboost_system-xgcc40-mt" in the project setting.</div> <div>4. Edit the main.cpp as below:</div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #643820">#include </span><iostream></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #643820">#include</span><boost/asio.hpp></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color: #aa0d91">int</span> main (<span style="color: #aa0d91">int</span> argc, <span style="color: #aa0d91">char</span> * <span style="color: #aa0d91">const</span> argv[])</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> boost::asio::io_service io_service;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>boost::asio::ip::tcp::acceptor acceptor(io_service);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16"><span style="color: #000000"> </span><span style="color: #5c2699">std</span><span style="color: #000000">::</span><span style="color: #5c2699">cout</span><span style="color: #000000"><<</span>"acceptor instantiated."<span style="color: #000000"><<</span><span style="color: #5c2699">std</span><span style="color: #000000">::endl;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>return<span style="color: #000000"> </span><span style="color: #1c00cf">0</span><span style="color: #000000">;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div></div><div>5. Build and run. Check out the result from the Console window as captured below:</div> <div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">[Session started at 2009-07-28 16:00:10 +0800.]</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h:127:</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b> error: attempt to copy-construct an iterator from a singular iterator.</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; min-height: 14.0px"><b></b><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>Objects involved in the operation:</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>iterator "this" @ 0x0x100480 {</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator);</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b> state = singular;</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>}</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>iterator "other" @ 0x0xbffff364 {</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator);</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b> state = singular;</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier"><b>}</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">[Session started at 2009-07-28 16:00:10 +0800.]</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">Copyright 2004 Free Software Foundation, Inc.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">GDB is free software, covered by the GNU General Public License, and you are</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">welcome to change it and/or distribute copies of it under certain conditions.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">Type "show copying" to see the conditions.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">There is absolutely no warranty for GDB. Type "show warranty" for details.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">Attaching to process 3497.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier">The Debugger Debugger is attaching to process</p></div><div><br></div><div>It generates a runtime error "<span class="Apple-style-span" style="font-family: Courier; font-size: 12px; font-weight: bold; ">error: attempt to copy-construct an iterator from a singular iterator.<span class="Apple-style-span" style="font-family: arial; font-size: small; font-weight: normal; ">".</span></span></div> <div><br></div><div><br></div><div>However, if I compile the code in terminal:</div><div><div>g++ -o test -g -Wall main.cpp -lboost_system-xgcc40-mt</div><div><br></div><div>It runs okay without any runtime error.</div><div> <br></div><div><br></div><br>Regards,<br><br>Victor Tsang<br><br> </div>