Skip to content

Commit 3d8fb18

Browse files
authored
Fix typeinfo for undefined sanitizer
This happened to me when I compiled my code on x86_64 linux (ubuntu 24.04) with clang-18 and everything except glibc built from source (llvm 19, llvm source) I found this solution and luckily it works! emscripten-core/emscripten#13367 emscripten-core/emscripten#13330 I saw that issue is abandoned, so I decided to try to push it in upstream
1 parent 815343e commit 3d8fb18

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcxx/include/typeinfo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ public:
315315

316316
_LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }
317317

318-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
318+
// We need to inline this code because otherwise we will get a stack overflow with undefined sanitizer.
319+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
319320
// When evaluated in a constant expression, both type infos simply can't come
320321
// from different translation units, so it is sufficient to compare their addresses.
321322
if (__libcpp_is_constant_evaluated()) {

0 commit comments

Comments
 (0)