[libc++] Temporarily silence failing debug mode test

Also, fix the actual code so that the test would pass if we fixed the
issue that the method is instantiated in the dylib, and hence the debug
assertion will never fire except if the debug mode is enabled when the
dylib is being compiled.
This commit is contained in:
Louis Dionne 2022-02-15 15:47:45 -05:00
parent 0736bbd7e2
commit 5c53afe5aa
2 changed files with 12 additions and 1 deletions

View File

@ -2870,6 +2870,10 @@ template <class _CharT, class _Traits, class _Allocator>
typename basic_string<_CharT, _Traits, _Allocator>::iterator
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
"string::insert(iterator, character) called with an iterator not"
" referring to this string");
size_type __ip = static_cast<size_type>(__pos - begin());
size_type __sz = size();
size_type __cap = capacity();

View File

@ -14,6 +14,12 @@
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// TODO: Since string::insert(iter, char) is intantiated in the dylib, this test doesn't
// actually work if the dylib hasn't been built with debug assertions enabled.
// Until we overhaul the debug mode, mark this test as unsupported to avoid
// spurious CI failures.
// REQUIRES: never-run
#include <string>
#include "test_macros.h"
@ -24,7 +30,8 @@ int main(int, char**)
typedef std::string S;
S s;
S s2;
TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'), "Attempted to subtract incompatible iterators");
TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'),
"string::insert(iterator, character) called with an iterator not referring to this string");
return 0;
}