[Boost-bugs] [Boost C++ Libraries] #11879: Incorrect use of reset cause unexpected impact on previous code segment

Subject: [Boost-bugs] [Boost C++ Libraries] #11879: Incorrect use of reset cause unexpected impact on previous code segment
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-12-30 08:40:42


#11879: Incorrect use of reset cause unexpected impact on previous code segment
-----------------------+------------------------------
 Reporter: anonymous | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.61.0
 Severity: Problem | Keywords:
-----------------------+------------------------------
 #include <boost/scoped_ptr.hpp>
 #include <iostream>

 int main()
 {
   boost::scoped_ptr<int> p{new int{1}};
   std::cout << *p << '\n';
   std::cout << p.get() << '\n';
   p.reset(new int{2});
   std::cout << *p.get() << '\n';
   std::cout << p.get() << '\n';

   p.reset((int *)4); //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.

   std::cout << *p.get() << '\n';
   std::cout << p.get() << '\n';

   p.reset();
   std::cout << std::boolalpha << static_cast<bool>(p) << '\n';
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11879>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC