This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
typeid strangeness
- To: gcc at gcc dot gnu dot org
- Subject: typeid strangeness
- From: Stefan Seefeld <seefeld at sympatico dot ca>
- Date: Tue, 17 Jul 2001 20:31:45 -0500
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