> George Heintzelman writes: > > Hi - I'm not sure if CINT supports C++ RTTI at all and dynamic cast in > particular - may be Masa can comment on it. However ROOT provides an equivalent > of dynamic cast which is > > Bool_t TObject::InheritsFrom(Text_t* classname) I know about this. It seems that the new version of root at least is compiled using the rtti on most platforms, even though it does not use dynamic_cast internally (which it should! but I digress...). One could expect that the compiler-level implementation of dynamic_cast (being a C++ keyword) may be very efficiently done. Therefore I was changing some compiled code (to be linked with root libraries) to use the dynamic_cast syntax, and just did some playing around in CINT first. What's clear, though, is that CINT's behavior with dynamic_cast is not correct, though it seems to understand the syntax. I note that CINT per se doesn't know about TObject and daughters. > At the same time I doubt that using the dynamic cast would help to solve > the problem you reported earlier today any better that "normal" C-style cast > would do. You defined an object which was both - Base and Derived - > simultaneously and asked the interpreter/compiler > to decide whether it was Base or Derived when the object was passed as > a parameter.... Looks like the perfect example of the situation where the > behaviour can be undefined. Right. I'm not suggesting that the two problems are linked. The first problem is something that the compiler/interpreter should resolve strictly from syntax, and I think CINT is resolving incorrectly (or at least non-intuitively). Perhaps I wasn't clear what I thought the problem was. Calling func with an argument which is a Base * should always call func(Base *). Calling func with an argument of Derived * should always call func(Derived *). In both of those cases CINT behaves correctly. Calling func with an argument of Derived2 *, it seems that the proper behavior would be to call func(Derived *), not func(Base *); and that is in fact what egcs does. I don't know what the ANSI C++ standard says about this. If anyone can point me to that document somewhere, I'll be happy to look it up... George Heintzelman gah@bnl.gov
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:39 MET