Skip to content

Commit 28e9535

Browse files
committed
Debug printf()s in type_equal_to
``` g++ (Debian 12.2.0-3) 12.2.0 ============================ LOOOK __GLIBCXX__ [lhs=N12_GLOBAL__N_110any_structE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/internals.h:124 LOOOK __GLIBCXX__ [rhs=N12_GLOBAL__N_110any_structE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/internals.h:125 LOOOK __GLIBCXX__ [(lhs==rhs)=FALSE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/internals.h:129 Debian clang version 14.0.6-2 ============================= LOOOK __GLIBCXX__ [lhs=N12_GLOBAL__N_110any_structE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/internals.h:124 LOOOK __GLIBCXX__ [rhs=N12_GLOBAL__N_110any_structE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/internals.h:125 LOOOK __GLIBCXX__ [(lhs==rhs)=TRUE] /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/internals.h:129 ImportError while loading conftest '/usr/local/google/home/rwgk/forked/pybind11/tests/conftest.py'. conftest.py:16: in <module> import pybind11_tests E ImportError: generic_type: type "unnamed_namespace_b_any_struct" is already registered! ```
1 parent 95caa03 commit 28e9535

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

include/pybind11/detail/internals.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,20 @@ inline void tls_replace_value(PYBIND11_TLS_KEY_REF key, void *value) {
117117
#if defined(__GLIBCXX__)
118118
inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) { return lhs == rhs; }
119119
using type_hash = std::hash<std::type_index>;
120-
using type_equal_to = std::equal_to<std::type_index>;
120+
// using type_equal_to = std::equal_to<std::type_index>;
121+
struct type_equal_to {
122+
bool operator()(const std::type_index &lhs, const std::type_index &rhs) const {
123+
bool result = (lhs == rhs);
124+
printf("\nLOOOK __GLIBCXX__ [lhs=%s] %s:%d\n", lhs.name(), __FILE__, __LINE__);
125+
printf("LOOOK __GLIBCXX__ [rhs=%s] %s:%d\n", rhs.name(), __FILE__, __LINE__);
126+
printf("LOOOK __GLIBCXX__ [(lhs==rhs)=%s] %s:%d\n",
127+
(result ? "TRUE" : "FALSE"),
128+
__FILE__,
129+
__LINE__);
130+
fflush(stdout);
131+
return result;
132+
}
133+
};
121134
#else
122135
inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) {
123136
return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0;
@@ -136,7 +149,16 @@ struct type_hash {
136149

137150
struct type_equal_to {
138151
bool operator()(const std::type_index &lhs, const std::type_index &rhs) const {
139-
return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0;
152+
// return lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0;
153+
bool result = (lhs.name() == rhs.name() || std::strcmp(lhs.name(), rhs.name()) == 0);
154+
printf("\nLOOOK ___OTHER___ [lhs=%s] %s:%d\n", lhs.name(), __FILE__, __LINE__);
155+
printf("LOOOK ___OTHER___ [rhs=%s] %s:%d\n", rhs.name(), __FILE__, __LINE__);
156+
printf("LOOOK ___OTHER___ [(lhs==rhs)=%s] %s:%d\n",
157+
(result ? "TRUE" : "FALSE"),
158+
__FILE__,
159+
__LINE__);
160+
fflush(stdout);
161+
return result;
140162
}
141163
};
142164
#endif

0 commit comments

Comments
 (0)