Boost C++ Libraries: Ticket #2823: [fusion] vector copy constructor copies sequence members in different order on different platforms https://svn.boost.org/trac10/ticket/2823 <p> The generalized fusion::vector copy constructor for constructing from arbitrary fusion sequences does its copying in reverse order on one of my machines. This does not occur with vector copy assignment, and does not occur at all with fusion::list (see attached code). </p> <p> In all my real world use this has not made a difference; I uncovered it in a unit test. The attached code shows what happens when you use transform_view to transform a fusion sequence with a stateful fusion functor. </p> <p> Correct order: Mac PPC OS 10.5.6 Darwin Kernel 9.6.0 gcc 4.2.1 </p> <p> Reverse order: Linux 2.6.9-42.0.3.ELsmp i686 i686 i386 gcc 4.2.4 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2823 Trac 1.4.3 dkomisar@… Tue, 03 Mar 2009 17:45:21 GMT attachment set https://svn.boost.org/trac10/ticket/2823 https://svn.boost.org/trac10/ticket/2823 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> Ticket dkomisar@… Mon, 23 Mar 2009 15:38:26 GMT <link>https://svn.boost.org/trac10/ticket/2823#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:1</guid> <description> <p> Took a look at the code and it looks like this is due to function call arguments being called in different orders on different platforms, so there's not much that can be done. I think that this really needs to be highlighted (at least mentioned) in the docs somewhere. </p> <p> I could be wrong though, I'm not very good at reading PP-intensive code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dean Michael Berris</dc:creator> <pubDate>Mon, 29 Nov 2010 03:32:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2823#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:2</guid> <description> <p> It looks like a compiler bug, should this be marked as <code>wontfix</code> appropriately, and have a different issue for the documentation changes? Joel? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 29 Nov 2010 03:41:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2823#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:3</guid> <description> <p> Dean, it's not a compiler bug. This is a known problem. The order of evaluation of function call arguments are undefined accd' to standard. Need further to look into this. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>René Rivera</dc:creator> <pubDate>Mon, 29 Nov 2010 04:12:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2823#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:4</guid> <description> <p> I've run into this problem recently, and bugged Hartmut about it on IRC. My solution to the implementation defined behavior that makes all fusion sequence operations have an unpredictable execution ordering. My solution was to create my own version of fusion::as_list that has a guaranteed execution order. The key being to make copies of the sequence values in the correct ordering. Which boils down to changing fusion::detail::build_cons&lt;First,Last,false&gt;::call(...) from: </p> <pre class="wiki">static type call(First const&amp; f, Last const&amp; l) { return type(*f, next_build_cons::call(fusion::next(f), l)); } </pre><p> To: </p> <pre class="wiki">static type call(First const&amp; f, Last const&amp; l) { typename result_of::value_of&lt;First&gt;::type v = *f; return type(v, next_build_cons::call(fusion::next(f), l)); } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Dean Michael Berris</dc:creator> <pubDate>Mon, 29 Nov 2010 09:13:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2823#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2823#comment:4" title="Comment 4">grafik</a>: </p> <blockquote class="citation"> <p> The key being to make copies of the sequence values in the correct ordering. Which boils down to changing fusion::detail::build_cons&lt;First,Last,false&gt;::call(...) from: </p> <p> ... </p> <p> To: </p> <p> ... </p> </blockquote> <p> Interesting. Let me try that locally and run the tests -- unfortunately I cannot test on multiple platforms. I'll attach the patch for testing. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dean Michael Berris</dc:creator> <pubDate>Mon, 29 Nov 2010 09:21:35 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2823 https://svn.boost.org/trac10/ticket/2823 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-fusion-issue2823.diff</span> </li> </ul> <p> Patch as proposed by Rene, applies to <a class="changeset" href="https://svn.boost.org/trac10/changeset/66834" title="Forget a ')'. ">r66834</a>. </p> Ticket Marshall Clow Fri, 07 Jan 2011 01:18:14 GMT <link>https://svn.boost.org/trac10/ticket/2823#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67745" title="Applied patch; refs #2823; will merge to release once tests cycle">[67745]</a>) Applied patch; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2823" title="#2823: Bugs: [fusion] vector copy constructor copies sequence members in different ... (closed: fixed)">#2823</a>; will merge to release once tests cycle </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Fri, 07 Jan 2011 01:21:21 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/2823#comment:7 https://svn.boost.org/trac10/ticket/2823#comment:7 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Joel de Guzman</span> to <span class="trac-author">Marshall Clow</span> </li> </ul> Ticket Marshall Clow Fri, 07 Jan 2011 01:56:42 GMT owner changed https://svn.boost.org/trac10/ticket/2823#comment:8 https://svn.boost.org/trac10/ticket/2823#comment:8 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Marshall Clow</span> to <span class="trac-author">Joel de Guzman</span> </li> </ul> <p> On-list, Steven Watanabe wrote: </p> <p> <em>&gt; result_of::deref would be better. There's no reason to make an extra copy. (Although this code looks pretty copy-happy to begin with). </em> </p> <p> Joel says that he will take it from here; assigning back to him. However, the patch that I applied <em>does</em> fix the bug. </p> Ticket Dean Michael Berris Fri, 07 Jan 2011 02:05:51 GMT <link>https://svn.boost.org/trac10/ticket/2823#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:9</guid> <description> <p> I've updated the patch (made against the latest in Trunk, 67745) which implements the suggestion. Please see the new attachment. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dean Michael Berris</dc:creator> <pubDate>Fri, 07 Jan 2011 02:06:38 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/2823 https://svn.boost.org/trac10/ticket/2823 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-fusion-issue2823-2.diff</span> </li> </ul> <p> Updated patch to take Steven's suggestion. </p> Ticket Marshall Clow Sat, 08 Jan 2011 18:47:45 GMT <link>https://svn.boost.org/trac10/ticket/2823#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2823#comment:10</guid> <description> <p> Fix merged to release branch in <a class="changeset" href="https://svn.boost.org/trac10/changeset/67792" title="Merging fixes to release; fixes #2294 fixes #4918 fixes #3645 refs ...">[67792]</a>; Joel will optimize more. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Fri, 12 Jun 2015 06:52:39 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2823#comment:11 https://svn.boost.org/trac10/ticket/2823#comment:11 <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> Ticket