
20 Apr
2009
20 Apr
'09
9:40 p.m.
Gennadiy Rozental:
Hi,
Following snippet compiles fine with 1.34.1
-------------------------- #include "boost/shared_ptr.hpp"
class Base { public: virtual ~Base() {} };
class Derived;
boost::shared_ptr<Base> foo() { return boost::shared_ptr<Derived>(); }
class Derived : public Base {};
This doesn't look legal to me. It does compile with MSVC (7.1) and g++ (3.4.6), and doesn't (as I would expect) with Como and Borland. At the point where foo is defined, there is no conversion from Derived* to Base*, so the instantiation of shared_ptr<Base>::shared_ptr<Base>( shared_ptr<Derived> const& ) would fail. I don't think that the compiler is required to postpone all template instantiations until the end of the translation unit.