Reputation: 4516
On the macOS system console this error is logged when launching one of my apps:
APP[28193]: dynamic_cast error 2: One or more of the following type_info's has hidden visibility. They should all have public visibility. 17CPPNameOfClassA, 28CPPNameOfClassB.
It does not impact functionality (yet) as far as I can tell but obviously something is wrong. Inspecting the source of this warning in the Clang sources also suggests that it has a performance impact.
This is generated for a framework including C++ classes used by other frameworks in my app referencing it.
FWIW, the warning is caused by the private_typeinfo.cpp
class in Clang (https://github.com/llvm-mirror/libcxxabi/blob/master/src/private_typeinfo.cpp).
According to the Controlling Symbol Visibility chapter in Apple's C++ Runtime Environment Programming Guide I should be able to control visibility on a class level with attributes or GCC pragmas.
Thing is the symbol is already visible as far as I can tell with nm
and my frameworks all already have Default
visibility (i.e. NOT Hidden
).
Also using either (attribute or pragma) to force default visibility causes the app to crash where it only created the warning before.
Weirdly this warning is only generated for some classes while a majority of other classes in the same compilation unit/framework don't cause any warnings.
Any further hints or ideas on how to fix this issue greatly appreciated!
Upvotes: 7
Views: 7200
Reputation: 21
This is an old question, but maybe this will help someone else with the same problem.
One of the reasons this could happen is that your app loads several different versions of the same library. For example in my case, I simply didn't remove a path to old version from library search path. Try to see (in debugger) what libraries are loaded in your app, and check that the same library wasn't loaded from different locations.
While trying to resolve this, I found these links useful: https://forums.wxwidgets.org/viewtopic.php?t=42566, http://www.russellmcc.com/posts/2013-08-03-rtti.html.
Upvotes: 2