From 5c53afe5aac0d295a9345cd439c6caf3ac5eb8ba Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 15 Feb 2022 15:47:45 -0500 Subject: [PATCH] [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. --- libcxx/include/string | 4 ++++ .../string.modifiers/insert_iter_char_db1.pass.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libcxx/include/string b/libcxx/include/string index fa42edde0aa1..809ae41a5bd7 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -2870,6 +2870,10 @@ template 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(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp index c6a81ebfa65a..ac05b69cf556 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp @@ -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 #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; }