Skip to content

Commit 00e44db

Browse files
authored
Merge pull request #795 from trcrsired/master
add correct asan support libc++'s string
2 parents afe2008 + d2f4f4b commit 00e44db

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/fast_io_unit/string_impl/libc++.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ inline void set_size(::std::basic_string<elem, traits, alloc> &str,
124124
decltype(auto) __r_{hack_rep(str)};
125125
if (bool(__r_.__s.__is_long_))
126126
{
127+
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
128+
if (!::std::__libcpp_is_constant_evaluated())
129+
{
130+
auto dataptr{str.data()};
131+
auto edptr{dataptr + __r_.__l.__size_};
132+
::std::__annotate_contiguous_container<alloc>(dataptr, dataptr + str.capacity(), dataptr + s + 1, edptr + 1);
133+
}
134+
#endif
127135
__r_.__l.__size_ = s;
128136
}
129137
else

include/fast_io_unit/string_impl/ostring_ref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ strlike_set_curr(io_strlike_type_t<char_type, ::std::basic_string<char_type, tra
111111
else
112112
#endif
113113
{
114-
traits_type::assign(*p, char_type());
115114
::fast_io::details::string_hack::set_end_ptr(str, p);
115+
traits_type::assign(*p, char_type());
116116
}
117117
}
118118

0 commit comments

Comments
 (0)