Skip to content

Conversation

@vmichal
Copy link
Contributor

@vmichal vmichal commented Dec 5, 2025

Impacts files in test/std/containers/container.adaptors/flat.xxx. No meaning is changed; only appropriate types are spelled out to prevent compiler warnings.

  • Replace chars and shorts used in tests of flat_[multi]{set, map} with longs to prevent warnings about narrowing conversions when running tests. Allow increased test coverage for MSVC STL.
  • Make test code robust against evil overloads of operator comma .(2 files)
  • Add [[maybe_unused]] to some local typedefs that are sometimes unused due to usage of LIBCPP_STATIC_ASSERT.

For discussion and suggested changes, see the LLVM Discord https://discord.com/channels/636084430946959380/636732894974312448/1445901676400742533

@vmichal vmichal requested a review from a team as a code owner December 5, 2025 19:33
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Dec 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 5, 2025

@llvm/pr-subscribers-libcxx

Author: Vojtěch Michal (vmichal)

Changes

Impacts files in test/std/containers/container.adaptors/flat.xxx

Replace chars and shorts used in tests of flat_[multi]{set, map} with longs to prevent warnings about narrowing conversions when running tests. Allow increased test coverage for MSVC STL.

Make test code robust against evil overloads of operator comma .(2 files)


Patch is 101.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/170909.diff

34 Files Affected:

  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp (+9-9)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp (+27-27)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp (+14-14)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp (+7-7)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp (+13-13)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp (+4-4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp (+6-6)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp (+13-13)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp (+6-6)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_initializer_list.pass.cpp (+8-8)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter.pass.cpp (+10-10)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/erase_key.pass.cpp (+6-6)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.observers/comp.pass.cpp (+1-1)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/copy_assign.pass.cpp (+9-9)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.pass.cpp (+27-27)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct_pmr.pass.cpp (+14-14)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/initializer_list.pass.cpp (+7-7)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter.pass.cpp (+13-13)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign.pass.cpp (+4-4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/pmr.pass.cpp (+6-6)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/range.pass.cpp (+13-13)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_container.pass.cpp (+14-14)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_initializer_list.pass.cpp (+11-11)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_iter_iter.pass.cpp (+10-10)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/erase_key.pass.cpp (+6-6)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.observers/comp.pass.cpp (+1-1)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp (+1-1)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_assign.pass.cpp (+5-4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_iter_iter.pass.cpp (+2-2)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator.pass.cpp (+1-1)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp (+1-1)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_assign.pass.cpp (+5-4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp (+2-2)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator.pass.cpp (+1-1)
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
index c98803f6cce9d..56231b8ee05bf 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
@@ -29,8 +29,8 @@ constexpr void test() {
     // test_allocator is not propagated
     using C = test_less<int>;
     KeyContainer<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
-    ValueContainer<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
-    using M = std::flat_map<int, char, C, decltype(ks), decltype(vs)>;
+    ValueContainer<long, test_allocator<long>> vs({2, 2, 1}, test_allocator<long>(7));
+    using M = std::flat_map<int, long, C, decltype(ks), decltype(vs)>;
     auto mo = M(ks, vs, C(5));
     auto m  = M({{3, 3}, {4, 4}, {5, 5}}, C(3), test_allocator<int>(2));
     m       = mo;
@@ -39,23 +39,23 @@ constexpr void test() {
     assert(m.keys() == ks);
     assert(m.values() == vs);
     assert(m.keys().get_allocator() == test_allocator<int>(2));
-    assert(m.values().get_allocator() == test_allocator<char>(2));
+    assert(m.values().get_allocator() == test_allocator<long>(2));
 
     // mo is unchanged
     assert(mo.key_comp() == C(5));
     assert(mo.keys() == ks);
     assert(mo.values() == vs);
     assert(mo.keys().get_allocator() == test_allocator<int>(6));
-    assert(mo.values().get_allocator() == test_allocator<char>(7));
+    assert(mo.values().get_allocator() == test_allocator<long>(7));
   }
   {
     // other_allocator is propagated
     using C  = test_less<int>;
     using Ks = KeyContainer<int, other_allocator<int>>;
-    using Vs = ValueContainer<char, other_allocator<char>>;
+    using Vs = ValueContainer<long, other_allocator<long>>;
     auto ks  = Ks({1, 3, 5}, other_allocator<int>(6));
-    auto vs  = Vs({2, 2, 1}, other_allocator<char>(7));
-    using M  = std::flat_map<int, char, C, Ks, Vs>;
+    auto vs  = Vs({2, 2, 1}, other_allocator<long>(7));
+    using M  = std::flat_map<int, long, C, Ks, Vs>;
     auto mo  = M(Ks(ks, other_allocator<int>(6)), Vs(vs, other_allocator<int>(7)), C(5));
     auto m   = M({{3, 3}, {4, 4}, {5, 5}}, C(3), other_allocator<int>(2));
     m        = mo;
@@ -64,14 +64,14 @@ constexpr void test() {
     assert(m.keys() == ks);
     assert(m.values() == vs);
     assert(m.keys().get_allocator() == other_allocator<int>(6));
-    assert(m.values().get_allocator() == other_allocator<char>(7));
+    assert(m.values().get_allocator() == other_allocator<long>(7));
 
     // mo is unchanged
     assert(mo.key_comp() == C(5));
     assert(mo.keys() == ks);
     assert(mo.values() == vs);
     assert(mo.keys().get_allocator() == other_allocator<int>(6));
-    assert(mo.values().get_allocator() == other_allocator<char>(7));
+    assert(mo.values().get_allocator() == other_allocator<long>(7));
   }
   if (!TEST_IS_CONSTANT_EVALUATED) {
     // comparator is copied and invariant is preserved
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
index 21166361b014b..7998bef2e87d8 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
@@ -33,19 +33,19 @@ using PC = std::pair<const int, long>;
 
 void test_copy() {
   {
-    std::flat_map<long, short> source = {{1, 2}, {2, 3}};
+    std::flat_map<long, int> source = {{1, 2}, {2, 3}};
     std::flat_map s(source);
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
   }
   {
-    std::flat_map<long, short, std::greater<long>> source = {{1, 2}, {2, 3}};
+    std::flat_map<long, int, std::greater<long>> source = {{1, 2}, {2, 3}};
     std::flat_map s{source}; // braces instead of parens
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
   }
   {
-    std::flat_map<long, short, std::greater<long>> source = {{1, 2}, {2, 3}};
+    std::flat_map<long, int, std::greater<long>> source = {{1, 2}, {2, 3}};
     std::flat_map s(source, std::allocator<int>());
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
@@ -54,14 +54,14 @@ void test_copy() {
 
 void test_containers() {
   std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+  std::deque<long, test_allocator<long>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({1, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
+  std::deque<long, test_allocator<long>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
+  const std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
   {
     std::flat_map s(ks, vs);
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 43);
@@ -69,7 +69,7 @@ void test_containers() {
   {
     std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs);
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 43);
@@ -77,7 +77,7 @@ void test_containers() {
   {
     std::flat_map s(ks, vs, test_allocator<long>(0, 44));
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 44);
     assert(s.values().get_allocator().get_id() == 44);
@@ -85,7 +85,7 @@ void test_containers() {
   {
     std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, test_allocator<long>(0, 44));
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 44);
     assert(s.values().get_allocator().get_id() == 44);
@@ -94,14 +94,14 @@ void test_containers() {
 
 void test_containers_compare() {
   std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+  std::deque<long, test_allocator<long>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 1}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
+  std::deque<long, test_allocator<long>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
+  const std::pair<int, long> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
   {
     std::flat_map s(ks, vs, std::greater<int>());
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 43);
@@ -109,7 +109,7 @@ void test_containers_compare() {
   {
     std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, std::greater<int>());
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 43);
@@ -117,7 +117,7 @@ void test_containers_compare() {
   {
     std::flat_map s(ks, vs, std::greater<int>(), test_allocator<long>(0, 44));
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 44);
     assert(s.values().get_allocator().get_id() == 44);
@@ -125,7 +125,7 @@ void test_containers_compare() {
   {
     std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, std::greater<int>(), test_allocator<long>(0, 44));
 
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 44);
     assert(s.values().get_allocator().get_id() == 44);
@@ -280,11 +280,11 @@ void test_initializer_list_compare() {
 }
 
 void test_from_range() {
-  std::list<std::pair<int, short>> r     = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
-  const std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
+  std::list<std::pair<int, long>> r     = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+  const std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
   {
     std::flat_map s(std::from_range, r);
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>>);
     assert(std::ranges::equal(s, expected));
   }
   {
@@ -292,10 +292,10 @@ void test_from_range() {
     ASSERT_SAME_TYPE(
         decltype(s),
         std::flat_map<int,
-                      short,
+                      long,
                       std::less<int>,
                       std::vector<int, test_allocator<int>>,
-                      std::vector<short, test_allocator<short>>>);
+                      std::vector<long, test_allocator<long>>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 42);
@@ -303,11 +303,11 @@ void test_from_range() {
 }
 
 void test_from_range_compare() {
-  std::list<std::pair<int, short>> r     = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
-  const std::pair<int, short> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
+  std::list<std::pair<int, long>> r     = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+  const std::pair<int, long> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
   {
     std::flat_map s(std::from_range, r, std::greater<int>());
-    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>>);
+    ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>>);
     assert(std::ranges::equal(s, expected));
   }
   {
@@ -315,10 +315,10 @@ void test_from_range_compare() {
     ASSERT_SAME_TYPE(
         decltype(s),
         std::flat_map<int,
-                      short,
+                      long,
                       std::greater<int>,
                       std::vector<int, test_allocator<int>>,
-                      std::vector<short, test_allocator<short>>>);
+                      std::vector<long, test_allocator<long>>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().get_id() == 42);
     assert(s.values().get_allocator().get_id() == 42);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
index 11c18ac13c76a..97eeec44bae3b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
@@ -32,19 +32,19 @@ using PC = std::pair<const int, long>;
 
 void test_containers() {
   std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+  std::deque<long, test_allocator<long>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({1, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
+  std::deque<long, test_allocator<long>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
+  const std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
   {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
     std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
-    std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
+    std::pmr::deque<long> pvs(vs.begin(), vs.end(), &mr);
     std::flat_map s(std::move(pks), std::move(pvs), &mr2);
 
     ASSERT_SAME_TYPE(
-        decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+        decltype(s), std::flat_map<int, long, std::less<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().resource() == &mr2);
     assert(s.values().get_allocator().resource() == &mr2);
@@ -53,11 +53,11 @@ void test_containers() {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
     std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
-    std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
+    std::pmr::deque<long> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
     std::flat_map s(std::sorted_unique, std::move(pks), std::move(pvs), &mr2);
 
     ASSERT_SAME_TYPE(
-        decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+        decltype(s), std::flat_map<int, long, std::less<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().resource() == &mr2);
     assert(s.values().get_allocator().resource() == &mr2);
@@ -66,19 +66,19 @@ void test_containers() {
 
 void test_containers_compare() {
   std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+  std::deque<long, test_allocator<long>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 1}, test_allocator<int>(0, 42));
-  std::deque<short, test_allocator<short>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
+  std::deque<long, test_allocator<long>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
+  const std::pair<int, long> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
   {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
     std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
-    std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
+    std::pmr::deque<long> pvs(vs.begin(), vs.end(), &mr);
     std::flat_map s(std::move(pks), std::move(pvs), std::greater<int>(), &mr2);
 
     ASSERT_SAME_TYPE(
-        decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+        decltype(s), std::flat_map<int, long, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().resource() == &mr2);
     assert(s.values().get_allocator().resource() == &mr2);
@@ -87,11 +87,11 @@ void test_containers_compare() {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
     std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
-    std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
+    std::pmr::deque<long> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
     std::flat_map s(std::sorted_unique, std::move(pks), std::move(pvs), std::greater<int>(), &mr2);
 
     ASSERT_SAME_TYPE(
-        decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+        decltype(s), std::flat_map<int, long, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
     assert(std::ranges::equal(s, expected));
     assert(s.keys().get_allocator().resource() == &mr2);
     assert(s.values().get_allocator().resource() == &mr2);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
index aea2002ba8d9c..ef49a6ee9f986 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
@@ -37,24 +37,24 @@ struct DefaultCtableComp {
 
 template <template <class...> class KeyContainer, template <class...> class ValueContainer>
 constexpr void test() {
-  std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
+  std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
   {
     // flat_map(initializer_list<value_type>);
-    using M                                         = std::flat_map<int, short>;
-    std::initializer_list<std::pair<int, short>> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    using M                                        = std::flat_map<int, long>;
+    std::initializer_list<std::pair<int, long>> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
     M m(il);
     assert(std::equal(m.begin(), m.end(), expected, expected + 4));
   }
   {
     // flat_map(initializer_list<value_type>);
     // explicit(false)
-    using M = std::flat_map<int, short>;
+    using M = std::flat_map<int, long>;
     M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
     assert(std::equal(m.begin(), m.end(), expected, expected + 4));
   }
   {
     // flat_map(initializer_list<value_type>);
-    using M = std::flat_map<int, short, std::greater<int>, KeyContainer<int, min_allocator<int>>>;
+    using M = std::flat_map<int, long, std::greater<int>, KeyContainer<int, min_allocator<int>>>;
     M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
     assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
   }
@@ -79,7 +79,7 @@ constexpr void test() {
   {
     // flat_map(initializer_list<value_type>, const key_compare&);
     using C = test_less<int>;
-    using M = std::flat_map<int, short, C>;
+    using M = std::flat_map<int, long, C>;
     auto m  = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10));
     assert(std::equal(m.begin(), m.end(), expected, expected + 4));
     assert(m.key_comp() == C(10));
@@ -92,7 +92,7 @@ constexpr void test() {
   if (!TEST_IS_CONSTANT_EVALUATED) {
     // flat_map(initializer_list<value_type>, const key_compare&);
     // Sorting uses the comparator that was passed in
-    usi...
[truncated]

@huixie90 huixie90 self-assigned this Dec 6, 2025
Copy link
Member

@huixie90 huixie90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comments and green CI

Copy link
Contributor

@frederick-vs-ja frederick-vs-ja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think we can merge this now.

@frederick-vs-ja
Copy link
Contributor

I'm removing this part from the PR description to avoid atting whenever pushing a commit.

If possible, I'd like to ask @huixie90 to verify whether this matches the recommended modifications.

@frederick-vs-ja frederick-vs-ja merged commit 72b4a5d into llvm:main Dec 7, 2025
82 checks passed
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

@vmichal Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@frederick-vs-ja
Copy link
Contributor

Oh no, it seems that you're not making you email address public for GitHub.

@vmichal
Copy link
Contributor Author

vmichal commented Dec 8, 2025

Oh no, it seems that you're not making you email address public for GitHub.

Eh, I have not noticed that. It should be fixed now. I hope its not a big issue.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 8, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-asan running on sanitizer-buildbot1 while building libcxx at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/13409

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:74: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 94420 tests, 64 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 
FAIL: LLVM :: ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll (58007 of 94420)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll    /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/Inputs/noop-main.ll | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# executed command: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/Inputs/noop-main.ll
# .---command stderr------------
# | JIT session error: In graph /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll.submodule.0xe775355f76151400.ll-jitted-objectbuffer, section .text: relocation target 0x7a7e2325702c (__orc_lcl.str3.3:0x7a7e23257030 + 0xfffffffffffffffc) is out of range of Delta32 fixup at address 0x7a7e23257030 (printf_wrapper, 0x767e22297000 + 0x3)
# | JIT session error: Failed to materialize symbols: { (main.impl, { printf_wrapper }) }
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# .---command stderr------------
# | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll:16:10: error: CHECK: expected string not found in input
# | ; CHECK: Goodbye from destructor
# |          ^
# | <stdin>:13:26: note: scanning from here
# | Goodbye from __cxa_atexit
# |                          ^
# | <stdin>:14:3: note: possible intended match here
# | [ printf_wrapper ]
# |   ^
# | 
# | Input file: <stdin>
# | Check file: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |             8: [ main ] 
# |             9: [ __lljit_run_atexits atexit ] 
# |            10: [ atexit_handler ] 
Step 11 (stage2/asan check) failure: stage2/asan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:564: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:74: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 94420 tests, 64 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 
FAIL: LLVM :: ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll (58007 of 94420)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll    /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/Inputs/noop-main.ll | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# executed command: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lli -jit-kind=orc-lazy -orc-lazy-debug=funcs-to-stdout -extra-module /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/Inputs/noop-main.ll
# .---command stderr------------
# | JIT session error: In graph /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll.submodule.0xe775355f76151400.ll-jitted-objectbuffer, section .text: relocation target 0x7a7e2325702c (__orc_lcl.str3.3:0x7a7e23257030 + 0xfffffffffffffffc) is out of range of Delta32 fixup at address 0x7a7e23257030 (printf_wrapper, 0x767e22297000 + 0x3)
# | JIT session error: Failed to materialize symbols: { (main.impl, { printf_wrapper }) }
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# .---command stderr------------
# | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll:16:10: error: CHECK: expected string not found in input
# | ; CHECK: Goodbye from destructor
# |          ^
# | <stdin>:13:26: note: scanning from here
# | Goodbye from __cxa_atexit
# |                          ^
# | <stdin>:14:3: note: possible intended match here
# | [ printf_wrapper ]
# |   ^
# | 
# | Input file: <stdin>
# | Check file: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |             8: [ main ] 
# |             9: [ __lljit_run_atexits atexit ] 
# |            10: [ atexit_handler ] 

honeygoyal pushed a commit to honeygoyal/llvm-project that referenced this pull request Dec 9, 2025
… tests for compatibility with MSVC (llvm#170909)

Impacts files in `test/std/containers/container.adaptors/flat.xxx`. No
meaning is changed; only appropriate types are spelled out to prevent
compiler warnings.

- Replace `char`s and `short`s used in tests of `flat_[multi]{set, map}`
with `long`s to prevent warnings about narrowing conversions when
running tests. Allow increased test coverage for MSVC STL.
- Make test code robust against evil overloads of operator comma .(2
files)
- Add `[[maybe_unused]]` to some local `typedef`s that are sometimes
unused due to usage of `LIBCPP_STATIC_ASSERT`.

For discussion and suggested changes, see the LLVM Discord
https://discord.com/channels/636084430946959380/636732894974312448/1445901676400742533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants