Hi, Running the following code: #include <memory> using namespace std; class CBase {}; class CDerived : public CBase {}; void Set(auto_ptr<CBase> base) { } int main(int argc, char *argv[]) { auto_ptr<CDerived> derived(new CDerived); Set(derived); // error: conversion from 'std::auto_ptr<CDerived>' to 'std::auto_ptr<CBase>' is ambiguous auto_ptr<CBase> base(derived); // but this is OK base = derived; // this is OK too } the Set(derived) gives the mentioned error in the comment. The next two lines compiles without error so both the copy constructor and the operator= of auto_ptr works fine. But for some reason the conversion is ambiguous if a function (in this case Set) is called. In the next two lines of the compiler output, there are two notes: /usr/include/c++/4.2.1/memory:368: note: candidates are: std::auto_ptr<_Tp>::operator std::auto_ptr<_Tp1>() [with _Tp1 = CBase, _Tp = CDerived] /usr/include/c++/4.2.1/memory:212: note: std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp1>&) [with _Tp1 = CDerived, _Tp = CBase] Please could you check if this is a bug or I made something wrong? Thanks, Csaba
*** Bug 34125 has been marked as a duplicate of this bug. ***
There isn't much to say: both the templated constructor and the templated conversion operator must be there per the current C++ standard, and your code cannot compile. Note that, in general, the design of auto_ptr is considered seriously broken and therefore it will be deprecated for the next standard and unique_ptr provided as replacement.