I was conducting an experiment and defined the same class both in a program and in a shared library that I dlopen from the program and made sure the program has no entry for the type info object in its dynsym table. Then I throw an object of that class from within the shared library and try to catch it using the same class type.
I expected that the implementation on linux and gcc would not catch the exception because the type info objects of both classes in the program and shared library differs, and therefore a match would only be possible if the runtime would do a string comparison of the mangled class names.
Still it matches, and I can even do dynamic downcasts to classes defined in the shared library. Can anyone please explain how the implementation works in this case, please?
Edit
Based on what the Itanium ABI states, the observed behavior would seem to be nonconforming. What am I missing here?
Therefore, except for direct or indirect pointers to incomplete types, the equality and inequality operators can be written as address comparisons when operating on those type_info objects: two type_info structures describe the same type if and only if they are the same structure (at the same address).
As the two typeinfo had different addresses, the structures described therefore represent different types. Therefore the cast should have failed and the exception should not have been caught.