Boost C++ Libraries: Ticket #3583: iterator in fusion::detail::segmented_range not adjusted after copying https://svn.boost.org/trac10/ticket/3583 <p> Consider the following code: </p> <pre class="wiki">boost::fusion::begin(boost::proto::flatten(a_ &gt;&gt; b_)) </pre><p> with a_ and b_ being two proto terminals. </p> <p> Internally this will yield to a local instantiation of fusion::detail::segmented_range&lt;boost::fusion::single_view&lt;boost::proto::exprns_::expr&lt;...&gt; &gt; &gt;. This segmented range view is copied in a fusion::cons, and this cons is returned to the caller <a class="ext-link" href="https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/view/ext_/segmented_iterator.hpp#L272"><span class="icon">​</span>segmented_iterator.hpp#L272</a> </p> <p> The iterator (segmented_range::where_) on the single view (segmented_range::sequence) is not adjusted when being copyed. Therefore the where_ attribute of the segmented_range in the cons points to an already destructed single view after the cons is returned to the caller. At the moment this is not much of a problem as single view iterators store a copy of the value of the actual single_view they point to (<a class="ext-link" href="https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/view/single_view/single_view_iterator.hpp"><span class="icon">​</span>single_view_iterator.hpp</a>). With the upcoming c++0x port of fusion this behaviour will change though. Single view iterators will store a pointer to the actual single view instead. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3583 Trac 1.4.3 Eric Niebler Thu, 05 Nov 2009 21:19:00 GMT <link>https://svn.boost.org/trac10/ticket/3583#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3583#comment:1</guid> <description> <p> Please either tell me how to reproduce the error or submit a patch. I don't really understand the problem based just on your description. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Christopher Schmidt</dc:creator> <pubDate>Thu, 05 Nov 2009 23:26:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3583#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3583#comment:2</guid> <description> <p> Apply the attached patch to a local copy of the TRUNK and run the proto "fusion.cpp" testcase. </p> <p> That's the output on my machine (gcc 4.4.1, MinGW) </p> <h6 class="section" id="BEGINOUTPUT">BEGIN OUTPUT</h6> <p> Running 1 test case... libs/proto/test/proto_fusion.cpp(93): error in "test1": check "(a&gt;&gt;b)(c&gt;&gt;d)" == sout.str() failed [(a&gt;&gt;b)(c&gt;&gt;d) != (ÿ&gt;&gt;ð)(c&gt;&gt;d)] </p> <p> <strong>* 1 failure detected in test suite "Master Test Suite" EXIT STATUS: 201 </strong></p> <h6 class="section" id="ENDOUTPUT">END OUTPUT</h6> </description> <category>Ticket</category> </item> <item> <dc:creator>Christopher Schmidt</dc:creator> <pubDate>Thu, 05 Nov 2009 23:27:26 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3583 https://svn.boost.org/trac10/ticket/3583 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fusion.diff</span> </li> </ul> Ticket Eric Niebler Fri, 13 Nov 2009 02:52:36 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3583#comment:3 https://svn.boost.org/trac10/ticket/3583#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/57622" title="avoid iterator invalidation in segmented_range, fixes #3583">[57622]</a>) avoid iterator invalidation in segmented_range, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3583" title="#3583: Bugs: iterator in fusion::detail::segmented_range not adjusted after copying (closed: fixed)">#3583</a> </p> Ticket