summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaron Keren <yaron.keren@gmail.com>2013-11-22 21:43:23 +0000
committerYaron Keren <yaron.keren@gmail.com>2013-11-22 21:43:23 +0000
commitd9eb5fc4502578e2d2a4df8c60c46970c36c4046 (patch)
treed3707dcc3ae098eec992b3e1b1cc6cae93fe5dd8
parent36fd93fd039ef14005d6ab51c2e9f2816d2b7063 (diff)
downloadlibcxxabi_35a-d9eb5fc4502578e2d2a4df8c60c46970c36c4046.tar.gz
On Windows, typeids are different between DLLs and EXEs, so comparing
type_info* will work for typeids from the same compiled file but fail for typeids from a DLL and an executable. Among other things, exceptions are not caught by handlers since can_catch() returns false. Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls is_equal() with use_strcmp=false so the string names are not compared. This patch compares typeids first (cheap) and only they are different calls strcmp. git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@195502 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--src/private_typeinfo.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/private_typeinfo.cpp b/src/private_typeinfo.cpp
index d43f772..52326a3 100644
--- a/src/private_typeinfo.cpp
+++ b/src/private_typeinfo.cpp
@@ -40,6 +40,18 @@
#include <sys/syslog.h>
#endif
+// On Windows, typeids are different between DLLs and EXEs, so comparing
+// type_info* will work for typeids from the same compiled file but fail
+// for typeids from a DLL and an executable. Among other things, exceptions
+// are not caught by handlers since can_catch() returns false.
+//
+// Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls
+// is_equal() with use_strcmp=false so the string names are not compared.
+
+#ifdef _WIN32
+#include <string.h>
+#endif
+
namespace __cxxabiv1
{
@@ -62,7 +74,11 @@ inline
bool
is_equal(const std::type_info* x, const std::type_info* y, bool)
{
+#ifndef _WIN32
return x == y;
+#else
+ return (x == y) || (strcmp(x->name(), y->name()) == 0);
+#endif
}
#endif // _LIBCXX_DYNAMIC_FALLBACK