public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* typeid strangeness
@ 2001-07-17 17:32 Stefan Seefeld
  2001-07-17 18:20 ` Ross Smith
  2001-07-18  8:09 ` Carlo Wood
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Seefeld @ 2001-07-17 17:32 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-07-18  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-17 17:32 typeid strangeness Stefan Seefeld
2001-07-17 18:20 ` Ross Smith
2001-07-17 18:34   ` Stefan Seefeld
2001-07-17 21:10     ` Ross Smith
2001-07-18  8:09 ` Carlo Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).