RE:Incorrect implementation of dynamic_cast

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Sep 02 1999 - 13:50:26 MEST


Hello George,

This is a known cint limitation which is described in  doc/limitati.txt
in cint source package.  All of following casting expressions behaves 
the same as C style casting in cint at this moment.


        dynamic_cast<T>(v)       same as   (T)v
        static_cast<T>(v)        same as   (T)v
        reinterpret_cast<T>(v)   same as   (T)v
        const_cast<T>(v)         same as   (T)v

Cint simply reads the syntax.

Thank you
Masaharu Goto

>
>Hi,
>
>I was playing around a bit with dynamic_cast<>, having read a bit more 
>in Stroustrup, who says:
>
>'dynamic_cast<T*>(p) looks at the object pointed to by p (if any). If 
>that object is of class T or has a unique base class of type T, then 
>dynamic_cast returns a pointer of type T* to that object; otherwise, 0 
>is returned.'
>
>This seems like very intuitive, useful, and meaningful behavior, and 
>shouldn't be too hard to implement either, since you've already got 
>dynamic type information running around.
>
>However, if in ROOT I do:
>
>class Base {
>   int foo;
>};
>
>class Derived {
>   int bar;
>};
>
>Derived *x = new Derived;
>Base *y = dynamic_cast<Base *>(x);  // This works, as it should;
>TObject *z = dynamic_cast<TObject *>(x); // This gives non-zero, 
>                                        // as it shouldn't!
>
>George Heintzelman
>gah@bnl.gov
>
>



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:39 MET