Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] post 1.34 regression
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-04-20 17:40:44


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk