Boost C++ Libraries: Ticket #11879: Incorrect use of reset cause unexpected impact on previous code segment https://svn.boost.org/trac10/ticket/11879 <p> #include &lt;boost/scoped_ptr.hpp&gt; #include &lt;iostream&gt; </p> <p> int main() { </p> <blockquote> <p> boost::scoped_ptr&lt;int&gt; p{new int<a class="report" href="https://svn.boost.org/trac10/report/1">{1}</a>}; std::cout &lt;&lt; *p &lt;&lt; '\n'; std::cout &lt;&lt; p.get() &lt;&lt; '\n'; p.reset(new int<a class="report" href="https://svn.boost.org/trac10/report/2">{2}</a>); std::cout &lt;&lt; *p.get() &lt;&lt; '\n'; std::cout &lt;&lt; p.get() &lt;&lt; '\n'; </p> </blockquote> <p> </p> <blockquote> <p> p.reset((int *)4); <em>Problem: Because of this statement std::cout of above lines are not printing anything. When this line is commented the program works fine. I understand I have used reset function incorrectly but it should impact to the next statements but it is also impacting above statements too. Please explain the cause. </em></p> </blockquote> <p> </p> <blockquote> <p> std::cout &lt;&lt; *p.get() &lt;&lt; '\n'; std::cout &lt;&lt; p.get() &lt;&lt; '\n'; </p> </blockquote> <p> </p> <blockquote> <p> p.reset(); std::cout &lt;&lt; std::boolalpha &lt;&lt; static_cast&lt;bool&gt;(p) &lt;&lt; '\n'; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11879 Trac 1.4.3 anonymous Wed, 30 Dec 2015 08:43:41 GMT <link>https://svn.boost.org/trac10/ticket/11879#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11879#comment:1</guid> <description> <p> I forgot to use wiki formatting. Comment start is missing from the statement p.reset((int *)4); </p> </description> <category>Ticket</category> </item> <item> <author>gunjan.rani100@…</author> <pubDate>Wed, 30 Dec 2015 08:52:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11879#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11879#comment:2</guid> <description> <p> In this case segmentation fault occurred with few other compilers. </p> </description> <category>Ticket</category> </item> <item> <author>gunjan.rani100@…</author> <pubDate>Wed, 30 Dec 2015 09:15:57 GMT</pubDate> <title>version changed https://svn.boost.org/trac10/ticket/11879#comment:3 https://svn.boost.org/trac10/ticket/11879#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.61.0</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> Ticket Steven Watanabe Fri, 01 Jan 2016 02:21:25 GMT <link>https://svn.boost.org/trac10/ticket/11879#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11879#comment:4</guid> <description> <p> std::cout is buffered. You'll get the result you expect, if you add a flush before the incorrect code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 03 Jan 2016 16:46:07 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/11879#comment:5 https://svn.boost.org/trac10/ticket/11879#comment:5 <ul> <li><strong>owner</strong> set to <span class="trac-author">Peter Dimov</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">smart_ptr</span> </li> </ul> Ticket anonymous Tue, 05 Jan 2016 10:32:21 GMT <link>https://svn.boost.org/trac10/ticket/11879#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11879#comment:6</guid> <description> <p> Why there is no exception handling for scoped_ptr creation? </p> </description> <category>Ticket</category> </item> </channel> </rss>