This is the mail archive of the gcc@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]

typeid strangeness


hi there,

I'm not certain whether my observations reflect a bug or
whether I have some profound misunderstanding. I'v got a
class tree based on a 'ServantBase' base class with methods
_add_ref() and _remove_ref().
For debugging purposes, I'd like to track these calls, so I
implement them like this:

void ServantBase::_add_ref()
{
   Guard<Mutex> guard(mutex);
   ++_refcount;
#ifdef LCLOG
   Logger::log(Logger::lifecycle) << "ServantBase::_add_ref on " << this << " ("
   << typeid(this).name() << "): new count is " << _refcount << std::endl;
#endif
}

and I'd (of course) like to see which specific subclass / instance gets called.
However, the type that is being reported is always the base class itself, not
the actual type. What is wrong ?
(this happens with gcc 2.95.x as well as gcc 3.0)

(passing the object reference into a function (void foo(const ServantBase &),
say) and evaluating the type there works fine).

Regards, 
Stefan


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