Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RTTI of local classes


  • To: cxx-abi@xxxxxxxxxxxxxxxxxxxx
  • Subject: RTTI of local classes
  • From: Martin von Loewis <loewis@xxxxxxxxxxxxxxxxxxxxxxx>
  • Date: Tue, 21 Mar 2000 22:45:30 +0100

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