This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: templates, derived classes, and dynamic_cast


Chris Mason wrote:

> There's nothing in (the 2 Dec 1999 draft version of) the C++ std which
> directly discusses dynamic_casting of templates.  So I can't say for
> sure if this code is or is not correct, as far as the standard is
> concerned.
The behaviour you see is what is expected.

>         ah->put(new Derived());
anyholder::put<Derived *&> is instantiated here and creates a
any<Derived *> holder.

>         ah->get(b);
anyholder::get<Base *&> is instantiated here. This tries to
do
	dynamic_cast <any<Base *> *> (b)
any<Base *> and any<Derived *> are sibling classes separately
derived from anybase. So the dynamic_cast fails.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]