Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2951: Unwanted implicit conversion from std::auto_ptr to boost:; shared_ptr
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-04-17 17:15:55
#2951: Unwanted implicit conversion from std::auto_ptr to boost:;shared_ptr
-------------------------------------------------+--------------------------
Reporter: William Tanenbaum <wmtan_at_[hidden]> | Owner: pdimov
Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: smart_ptr
Version: Boost 1.38.0 | Severity: Regression
Resolution: | Keywords: implicit conversion shared pointer
-------------------------------------------------+--------------------------
Comment(by wmtan_at_[hidden]):
//The following code compiles and runs.
An auto_ptr lvalue is implicitly converted to a shared_ptr.
This should not happen. This happens in gcc4.3 and gcc3.4,
with no compiler options other than -I to include the boost header.
#include <memory>
#include <iostream>
#include "boost/shared_ptr.hpp"
struct X {
int i;
};
void
f(boost::shared_ptr<X> sp) {
std::cout << sp->i << std::endl;
}
int
main() {
std::auto_ptr<X> ap(new X);
ap->i = 1;
f(ap);
}
~
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2951#comment:3> 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:00 UTC