Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr failure with undefined type (msvc)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-02-15 12:43:30


AMDG

On 2/15/2011 9:35 AM, Gennadiy Rozental wrote:
> I came to expect shared_ptr to handle undefined type, but here I got a test case
> (simplified from my use case) where it's actually breaks under msvc and works
> under gcc:
>
> #include "boost/shared_ptr.hpp"
>
> class UndefinedType;
>
> //// base class for template
> class FooBase{
> public:
> virtual ~FooBase();
>
> virtual void fff();
> };
>
> template<typename T>
> class Foo: public FooBase {
> public:
> virtual void fff()
> {
> // any virtual implementations seen are [have to be able to be]
> instantiated. This fails unless T is visible.
> x.reset(x.get());
> }
>
> private:
> boost::shared_ptr<T> x;
> };
>
>
> //// now use Foo as a field in a class
> class User {
> Foo<UndefinedType> y;
> };
>
> It fails with:
>
> ...\boost-1.39\boost/checked_delete.hpp(32) : error C2027: use of undefined type
> 'UndefinedType'
>
> Is this expected to compile? Is this MSVC issue?
>

Creating a shared_ptr from a raw pointer requires
a complete type, unless you pass a deleter.
MSVC must be instantiating Foo::fff sooner than
gcc is.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net