RTTI of local classes

Martin von Loewis loewis at informatik.hu-berlin.de
Tue Mar 21 21:45:30 UTC 2000


I was just reviewing the RTTI spec and see that type_info equalness is
based on type name mangling; this seems to be the right solution.

However, I think there are examples that break under that scheme:

struct Base{
  virtual ~Base();
};

static bool foo(Base* x){
  struct Derived:Base{};
  Base *y = new Derived;
  return typeid(*x)==typeid(*y);
}

typeinfo(*y).name() would be "Z3fooP4BaseE1_", right? Now, that could
also be the name of *x, if that was created in a different translation
unit, which also has a function foo(Base*) with a local type Derived.

I'm not sure about a conclusion. Is that well-formed C++ code with a
well-defined behaviour? Does our ABI support that? Should it? Is that
a defect in C++, as it is unimplementable?

Comments appreciated,
Martin





More information about the cxx-abi-dev mailing list