Boost C++ Libraries: Ticket #7900: karma indirect_iterator returns reference to temporary https://svn.boost.org/trac10/ticket/7900 <p> Hello, </p> <p> The indirect_iterator in boost/spirit/home/karma/detail/indirect_iterator.hpp returns a reference to a temporary in at least one corner case. The compiler will issue a warning, but it's still UB. </p> <p> I attached the minimal code to reproduce the behavior as well as a fix. Without the fix, it will print crap and issue a warning (on Clang and GCC). </p> <p> What happens: I create a transformed_range, which uses a transform_iterator under the hood. Since the function performing the transformation returns by value, the the iterator_traits&lt;transform_iterator&gt;::reference type is NOT the same as iterator_traits&lt;transform_iterator&gt;::value_type const&amp;, hence the return of a reference to a temporary. </p> <p> My setup: </p> <blockquote> <p> gcc version 4.7.2 clang version 3.2 boost-trunk@82516 </p> </blockquote> <p> Best, </p> <p> Louis Dionne </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7900 Trac 1.4.3 Louis Dionne <louis.dionne92@…> Thu, 17 Jan 2013 07:05:14 GMT attachment set https://svn.boost.org/trac10/ticket/7900 https://svn.boost.org/trac10/ticket/7900 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">indirect_iterator.diff</span> </li> </ul> <p> fix for the issue </p> Ticket Louis Dionne <louis.dionne92@…> Thu, 17 Jan 2013 07:05:50 GMT attachment set https://svn.boost.org/trac10/ticket/7900 https://svn.boost.org/trac10/ticket/7900 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> <p> minimal code to reproduce the issue </p> Ticket Louis Dionne <louis.dionne92@…> Thu, 17 Jan 2013 07:09:40 GMT <link>https://svn.boost.org/trac10/ticket/7900#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7900#comment:1</guid> <description> <p> Sorry for the mis-formatting of my setup. Should've previewed the ticket before posting! </p> <p> My setup: </p> <blockquote> <p> gcc version 4.7.2 </p> </blockquote> <blockquote> <p> clang version 3.2 </p> </blockquote> <blockquote> <p> boost-trunk@82516 </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 17 Jan 2013 10:49:14 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/7900#comment:2 https://svn.boost.org/trac10/ticket/7900#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Joel de Guzman</span> to <span class="trac-author">Hartmut Kaiser</span> </li> </ul> Ticket Hartmut Kaiser Thu, 17 Jan 2013 13:34:00 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7900#comment:3 https://svn.boost.org/trac10/ticket/7900#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/82521" title="Fix #7900: karma indirect_iterator returns reference to temporary">[82521]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7900" title="#7900: Patches: karma indirect_iterator returns reference to temporary (closed: fixed)">#7900</a>: karma indirect_iterator returns reference to temporary </p> Ticket