[libcxx-commits] [libcxx] 5c53afe - [libc++] Temporarily silence failing debug mode test

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 15 12:49:48 PST 2022


Author: Louis Dionne
Date: 2022-02-15T15:49:29-05:00
New Revision: 5c53afe5aac0d295a9345cd439c6caf3ac5eb8ba

URL: https://github.com/llvm/llvm-project/commit/5c53afe5aac0d295a9345cd439c6caf3ac5eb8ba
DIFF: https://github.com/llvm/llvm-project/commit/5c53afe5aac0d295a9345cd439c6caf3ac5eb8ba.diff

LOG: [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.

Added: 
    

Modified: 
    libcxx/include/string
    libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string b/libcxx/include/string
index fa42edde0aa15..809ae41a5bd74 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -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();

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 c6a81ebfa65ae..ac05b69cf5561 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 <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;
 }


        


More information about the libcxx-commits mailing list