[libcxx-commits] [libcxx] [libc++][test] Avoid narrowing operations in `pair`'s constructors for tests for `flat_(multi)map` whenever feasible (PR #131284)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 14 10:25:13 PDT 2025


https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/131284

>From 1553c22353fab31bbb0dfcdf305ba26d4af2964c Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Fri, 14 Mar 2025 14:26:05 +0800
Subject: [PATCH] [libc++][test] Avoid narrowing operations in `pair`'
 constructors

... for test files for `flat_(multi)map` whenever feasible.

Drive-by: Add `[[maybe_unused]]` to variables that are only used in
`LIBCPP_ASSERT`.

When testing MSVC STL, MSVC warns about such narrowing in `pair`'s
constructors, even though the narrowing happens within
direct-non-list-initialization.
---
 .../flat.map.cons/copy_assign.pass.cpp        |  8 ++-
 .../flat.map/flat.map.cons/deduct.pass.cpp    | 44 ++++++++++++---
 .../flat.map.cons/deduct_pmr.pass.cpp         | 12 +++-
 .../flat.map.cons/initializer_list.pass.cpp   | 51 ++++++++++++++---
 .../flat.map/flat.map.cons/iter_iter.pass.cpp | 15 ++++-
 .../flat.map.cons/move_assign.pass.cpp        | 15 +++--
 .../flat.map/flat.map.cons/pmr.pass.cpp       | 30 ++++++++--
 .../flat.map/flat.map.cons/range.pass.cpp     | 15 ++++-
 .../flat.map.cons/sorted_container.pass.cpp   | 25 +++++++--
 .../sorted_initializer_list.pass.cpp          | 19 +++++--
 .../flat.map.cons/sorted_iter_iter.pass.cpp   | 13 ++++-
 .../erase_if_exceptions.pass.cpp              |  3 +-
 .../flat.map.modifiers/erase_key.pass.cpp     |  2 +-
 .../flat.multimap.cons/containers.pass.cpp    | 33 ++++++++++-
 .../flat.multimap.cons/copy_assign.pass.cpp   |  8 ++-
 .../flat.multimap.cons/deduct.pass.cpp        | 54 +++++++++++++++---
 .../flat.multimap.cons/deduct_pmr.pass.cpp    | 18 +++++-
 .../initializer_list.pass.cpp                 | 56 ++++++++++++++++---
 .../flat.multimap.cons/iter_iter.pass.cpp     | 24 +++++++-
 .../flat.multimap.cons/move_assign.pass.cpp   | 19 +++++--
 .../flat.multimap.cons/pmr.pass.cpp           | 48 ++++++++++++++--
 .../flat.multimap.cons/range.pass.cpp         | 24 +++++++-
 .../sorted_container.pass.cpp                 | 20 +++++--
 .../sorted_initializer_list.pass.cpp          | 19 +++++--
 .../sorted_iter_iter.pass.cpp                 | 13 +++--
 .../erase_if_exceptions.pass.cpp              |  3 +-
 .../erase_key.pass.cpp                        |  2 +-
 27 files changed, 488 insertions(+), 105 deletions(-)

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 4f9797d5bf810..cc80de8950738 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,7 +29,9 @@ int main(int, char**) {
     std::vector<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
     using M = std::flat_map<int, char, 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));
+    auto m  = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+               C(3),
+               test_allocator<int>(2));
     m       = mo;
 
     assert(m.key_comp() == C(5));
@@ -54,7 +56,9 @@ int main(int, char**) {
     auto vs  = Vs({2, 2, 1}, other_allocator<char>(7));
     using M  = std::flat_map<int, char, 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));
+    auto m   = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+               C(3),
+               other_allocator<int>(2));
     m        = mo;
 
     assert(m.key_comp() == C(5));
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 009392feb3862..3ca7aa1363856 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
@@ -31,19 +31,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, short> source = {{1, static_cast<short>(2)}, {2, static_cast<short>(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, short, std::greater<long>> source = {{1, static_cast<short>(2)}, {2, static_cast<short>(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, short, std::greater<long>> source = {{1, static_cast<short>(2)}, {2, static_cast<short>(3)}};
     std::flat_map s(source, std::allocator<int>());
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
@@ -55,7 +55,11 @@ void test_containers() {
   std::deque<short, test_allocator<short>> 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}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {3, static_cast<short>(5)},
+      {INT_MAX, static_cast<short>(4)}};
   {
     std::flat_map s(ks, vs);
 
@@ -95,7 +99,11 @@ void test_containers_compare() {
   std::deque<short, test_allocator<short>> 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}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)}};
   {
     std::flat_map s(ks, vs, std::greater<int>());
 
@@ -278,8 +286,17 @@ 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, short>> r = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)},
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {3, static_cast<short>(5)},
+      {INT_MAX, static_cast<short>(4)}};
   {
     std::flat_map s(std::from_range, r);
     ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>>);
@@ -301,8 +318,17 @@ 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, short>> r = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)},
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(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>>);
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..e62b9049859aa 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
@@ -35,7 +35,11 @@ void test_containers() {
   std::deque<short, test_allocator<short>> 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}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {3, static_cast<short>(5)},
+      {INT_MAX, static_cast<short>(4)}};
   {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
@@ -69,7 +73,11 @@ void test_containers_compare() {
   std::deque<short, test_allocator<short>> 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}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)}};
   {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_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 7a22746845d00..5fa8b040a31e8 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
@@ -82,11 +82,18 @@ int main(int, char**) {
         !std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, std::allocator<int>>);
   }
 
-  std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
+  std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)}, {2, static_cast<short>(2)}, {3, static_cast<short>(3)}, {5, static_cast<short>(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}};
+    std::initializer_list<std::pair<int, short>> il = {
+        {5, static_cast<short>(2)},
+        {2, static_cast<short>(2)},
+        {2, static_cast<short>(2)},
+        {3, static_cast<short>(3)},
+        {1, static_cast<short>(1)},
+        {3, static_cast<short>(3)}};
     M m(il);
     assert(std::equal(m.begin(), m.end(), expected, expected + 4));
   }
@@ -94,13 +101,23 @@ int main(int, char**) {
     // flat_map(initializer_list<value_type>);
     // explicit(false)
     using M = std::flat_map<int, short>;
-    M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    M m     = {{5, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {3, static_cast<short>(3)},
+               {1, static_cast<short>(1)},
+               {3, static_cast<short>(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>, std::deque<int, min_allocator<int>>>;
-    M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    M m     = {{5, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {3, static_cast<short>(3)},
+               {1, static_cast<short>(1)},
+               {3, static_cast<short>(3)}};
     assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
   }
   {
@@ -127,12 +144,25 @@ int main(int, char**) {
     // flat_map(initializer_list<value_type>, const key_compare&);
     using C = test_less<int>;
     using M = std::flat_map<int, short, C>;
-    auto m  = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10));
+    auto m =
+        M({{5, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {3, static_cast<short>(3)},
+           {1, static_cast<short>(1)},
+           {3, static_cast<short>(3)}},
+          C(10));
     assert(std::equal(m.begin(), m.end(), expected, expected + 4));
     assert(m.key_comp() == C(10));
 
     // explicit(false)
-    M m2 = {{{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10)};
+    M m2 = {{{5, static_cast<short>(2)},
+             {2, static_cast<short>(2)},
+             {2, static_cast<short>(2)},
+             {3, static_cast<short>(3)},
+             {1, static_cast<short>(1)},
+             {3, static_cast<short>(3)}},
+            C(10)};
     assert(m2 == m);
     assert(m2.key_comp() == C(10));
   }
@@ -140,7 +170,14 @@ int main(int, char**) {
     // flat_map(initializer_list<value_type>, const key_compare&);
     // Sorting uses the comparator that was passed in
     using M = std::flat_map<int, short, std::function<bool(int, int)>, std::deque<int, min_allocator<int>>>;
-    auto m  = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, std::greater<int>());
+    auto m =
+        M({{5, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {3, static_cast<short>(3)},
+           {1, static_cast<short>(1)},
+           {3, static_cast<short>(3)}},
+          std::greater<int>());
     assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
     assert(m.key_comp()(2, 1) == true);
   }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
index 7c0c487969943..6fb6eef67bb03 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
@@ -57,9 +57,18 @@ int main(int, char**) {
     static_assert(!std::is_constructible_v<M3, Iter3, Iter3, const C&, const A2&>);
   }
 
-  using P      = std::pair<int, short>;
-  P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-  P expected[] = {{1, 1}, {2, 4}, {3, 6}};
+  using P = std::pair<int, short>;
+  P ar[]  = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(6)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
+  P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
   {
     // flat_map(InputIterator , InputIterator)
     // cpp17_input_iterator
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
index a94c442c695dd..ad305ae41cdf2 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
@@ -32,10 +32,10 @@ int main(int, char**) {
     using A1 = test_allocator<int>;
     using A2 = test_allocator<char>;
     using M  = std::flat_map<int, char, C, std::vector<int, A1>, std::vector<char, A2>>;
-    M mo     = M({{1, 1}, {2, 3}, {3, 2}}, C(5), A1(7));
+    M mo     = M({{1, static_cast<char>(1)}, {2, static_cast<char>(3)}, {3, static_cast<char>(2)}}, C(5), A1(7));
     M m      = M({}, C(3), A1(7));
     m        = std::move(mo);
-    assert((m == M{{1, 1}, {2, 3}, {3, 2}}));
+    assert((m == M{{1, static_cast<char>(1)}, {2, static_cast<char>(3)}, {3, static_cast<char>(2)}}));
     assert(m.key_comp() == C(5));
     auto [ks, vs] = std::move(m).extract();
     assert(ks.get_allocator() == A1(7));
@@ -47,10 +47,15 @@ int main(int, char**) {
     using A1 = other_allocator<int>;
     using A2 = other_allocator<char>;
     using M  = std::flat_map<int, char, C, std::deque<int, A1>, std::deque<char, A2>>;
-    M mo     = M({{4, 5}, {5, 4}}, C(5), A1(7));
-    M m      = M({{1, 1}, {2, 2}, {3, 3}, {4, 4}}, C(3), A1(7));
+    M mo     = M({{4, static_cast<char>(5)}, {5, static_cast<char>(4)}}, C(5), A1(7));
+    M m      = M({{1, static_cast<char>(1)}, //
+                  {2, static_cast<char>(2)},
+                  {3, static_cast<char>(3)},
+                  {4, static_cast<char>(4)}},
+            C(3),
+            A1(7));
     m        = std::move(mo);
-    assert((m == M{{4, 5}, {5, 4}}));
+    assert((m == M{{4, static_cast<char>(5)}, {5, static_cast<char>(4)}}));
     assert(m.key_comp() == C(5));
     auto [ks, vs] = std::move(m).extract();
     assert(ks.get_allocator() == A1(7));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
index 154af11bb9b4d..d1c86bb077ed5 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
@@ -166,9 +166,18 @@ int main(int, char**) {
   }
   {
     // flat_map(InputIterator first, InputIterator last, const Allocator& a);
-    using P      = std::pair<int, short>;
-    P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-    P expected[] = {{1, 1}, {2, 4}, {3, 6}};
+    using P = std::pair<int, short>;
+    P ar[]  = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {3, static_cast<short>(6)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
+    P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
     {
       //  cpp17 iterator
       using M = std::flat_map<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
@@ -242,9 +251,18 @@ int main(int, char**) {
   }
   {
     //  flat_map(from_range_t, R&&, const Alloc&);
-    using P      = std::pair<int, short>;
-    P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-    P expected[] = {{1, 1}, {2, 4}, {3, 6}};
+    using P = std::pair<int, short>;
+    P ar[]  = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {3, static_cast<short>(6)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
+    P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
     {
       // input_range
       using M    = std::flat_map<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
index 282cc71f31994..c34109a1801ba 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
@@ -117,9 +117,18 @@ int main(int, char**) {
     static_assert(!std::is_constructible_v<M, std::from_range_t, std::vector<NonPairLike>&, const C&, const A1&>);
   }
 
-  using P      = std::pair<int, short>;
-  P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-  P expected[] = {{1, 1}, {2, 4}, {3, 6}};
+  using P = std::pair<int, short>;
+  P ar[]  = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(6)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
+  P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
   {
     // flat_map(from_range_t, R&&)
     // input_range && !common
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
index 3c8868f2ff424..bde86ea2ddbe4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
@@ -66,11 +66,17 @@ int main(int, char**) {
     auto vs2             = vs;
 
     auto m = M(std::sorted_unique, ks, vs);
-    assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
     m = M(std::sorted_unique, std::move(ks), std::move(vs));
     assert(ks.empty()); // it was moved-from
     assert(vs.empty()); // it was moved-from
-    assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
 
     // explicit(false)
     M m2 = {std::sorted_unique, std::move(ks2), std::move(vs2)};
@@ -85,11 +91,17 @@ int main(int, char**) {
     Ks ks    = {10, 4, 2, 1};
     Vs vs    = {1, 2, 3, 4};
     auto m   = M(std::sorted_unique, ks, vs);
-    assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
     m = M(std::sorted_unique, std::move(ks), std::move(vs));
     assert(ks.empty()); // it was moved-from
     assert(vs.empty()); // it was moved-from
-    assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
   }
   {
     // flat_map(sorted_unique_t, key_container_type , mapped_container_type)
@@ -113,7 +125,10 @@ int main(int, char**) {
     std::vector<char> vs = {4, 3, 2, 1};
 
     auto m = M(std::sorted_unique, ks, vs, C(4));
-    assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
     assert(m.key_comp() == C(4));
 
     // explicit(false)
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_initializer_list.pass.cpp
index 26452472ba201..343cc57ad12bf 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_initializer_list.pass.cpp
@@ -31,7 +31,11 @@
 #include "../../../test_compare.h"
 
 template <class T, class U>
-std::initializer_list<std::pair<T, U>> il = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+std::initializer_list<std::pair<T, U>> il = {
+    {static_cast<T>(1), static_cast<U>(1)},
+    {static_cast<T>(2), static_cast<U>(2)},
+    {static_cast<T>(4), static_cast<U>(4)},
+    {static_cast<T>(5), static_cast<U>(5)}};
 
 const auto il1 = il<int, int>;
 const auto il2 = il<int, short>;
@@ -140,7 +144,8 @@ int main(int, char**) {
     using A2      = test_allocator<short>;
     using M       = std::flat_map<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
     auto m        = M(std::sorted_unique, il2, A1(5));
-    auto expected = M{{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+    auto expected = M{
+        {1, static_cast<short>(1)}, {2, static_cast<short>(2)}, {4, static_cast<short>(4)}, {5, static_cast<short>(5)}};
     assert(m == expected);
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -158,7 +163,10 @@ int main(int, char**) {
     using A2 = test_allocator<short>;
     using M  = std::flat_map<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
     auto m   = M(std::sorted_unique, il2, C(3), A1(5));
-    assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{1, static_cast<short>(1)},
+                   {2, static_cast<short>(2)},
+                   {4, static_cast<short>(4)},
+                   {5, static_cast<short>(5)}}));
     assert(m.key_comp() == C(3));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -170,7 +178,10 @@ int main(int, char**) {
     using A2 = test_allocator<int>;
     using M  = std::flat_map<short, int, std::less<int>, std::deque<short, A1>, std::vector<int, A2>>;
     M m      = {std::sorted_unique, il3, {}, A1(5)}; // implicit ctor
-    assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{static_cast<short>(1), 1},
+                   {static_cast<short>(2), 2},
+                   {static_cast<short>(4), 4},
+                   {static_cast<short>(5), 5}}));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
   }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter.pass.cpp
index 8eb7547e917cc..3b27e684ec91b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter.pass.cpp
@@ -128,7 +128,8 @@ int main(int, char**) {
     using P       = std::pair<int, int>;
     P ar[]        = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
     auto m        = M(std::sorted_unique, ar, ar + 4, A1(5));
-    auto expected = M{{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+    auto expected = M{
+        {1, static_cast<short>(1)}, {2, static_cast<short>(2)}, {4, static_cast<short>(4)}, {5, static_cast<short>(5)}};
     assert(m == expected);
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -148,7 +149,10 @@ int main(int, char**) {
     using P  = std::pair<int, int>;
     P ar[]   = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
     auto m   = M(std::sorted_unique, ar, ar + 4, C(3), A1(5));
-    assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{1, static_cast<short>(1)},
+                   {2, static_cast<short>(2)},
+                   {4, static_cast<short>(4)},
+                   {5, static_cast<short>(5)}}));
     assert(m.key_comp() == C(3));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -162,7 +166,10 @@ int main(int, char**) {
     using P  = std::pair<int, int>;
     P ar[]   = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
     M m      = {std::sorted_unique, ar, ar + 4, {}, A1(5)}; // implicit ctor
-    assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{static_cast<short>(1), 1},
+                   {static_cast<short>(2), 2},
+                   {static_cast<short>(4), 4},
+                   {static_cast<short>(5), 5}}));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
   }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
index 48fdec42db3fc..c0e31dc38426c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
@@ -66,7 +66,8 @@ struct ErasurePredicate {
 };
 
 int main(int, char**) {
-  const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+  [[maybe_unused]] const std::pair<int, int> expected[] = {
+      {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
   {
     using M = std::flat_map<ThrowingAssignment, int, ThrowingComparator>;
     for (int first_throw = 1; first_throw < 99; ++first_throw) {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/erase_key.pass.cpp
index ef57b1cb5512d..d019c5eeaa1b9 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/erase_key.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/erase_key.pass.cpp
@@ -32,7 +32,7 @@ void test() {
   auto make = [](std::initializer_list<int> il) {
     M m;
     for (int i : il) {
-      m.emplace(i, i);
+      m.emplace(i, static_cast<char>(i));
     }
     return m;
   };
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/containers.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/containers.pass.cpp
index 17ee3c3864b1b..f78f984dc6992 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/containers.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/containers.pass.cpp
@@ -71,7 +71,16 @@ int main(int, char**) {
     std::vector<int> ks             = {1, 1, 1, 2, 2, 3, 2, 3, 3};
     std::vector<char> vs            = {1, 2, 3, 4, 5, 6, 7, 8, 9};
     auto m                          = M(ks, vs);
-    std::pair<int, char> expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+    std::pair<int, char> expected[] = {
+        {1, static_cast<char>(1)},
+        {1, static_cast<char>(2)},
+        {1, static_cast<char>(3)},
+        {2, static_cast<char>(4)},
+        {2, static_cast<char>(5)},
+        {2, static_cast<char>(7)},
+        {3, static_cast<char>(6)},
+        {3, static_cast<char>(8)},
+        {3, static_cast<char>(9)}};
     assert(std::ranges::equal(m, expected));
 
     // explicit(false)
@@ -123,7 +132,16 @@ int main(int, char**) {
     std::vector<int> ks             = {1, 1, 1, 2, 2, 3, 2, 3, 3};
     std::vector<char> vs            = {1, 2, 3, 4, 5, 6, 7, 8, 9};
     auto m                          = M(ks, vs, C(4));
-    std::pair<int, char> expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+    std::pair<int, char> expected[] = {
+        {1, static_cast<char>(1)},
+        {1, static_cast<char>(2)},
+        {1, static_cast<char>(3)},
+        {2, static_cast<char>(4)},
+        {2, static_cast<char>(5)},
+        {2, static_cast<char>(7)},
+        {3, static_cast<char>(6)},
+        {3, static_cast<char>(8)},
+        {3, static_cast<char>(9)}};
     assert(std::ranges::equal(m, expected));
     assert(m.key_comp() == C(4));
 
@@ -169,7 +187,16 @@ int main(int, char**) {
     std::vector<int, A> ks          = {1, 1, 1, 2, 2, 3, 2, 3, 3};
     std::vector<int, A> vs          = {1, 2, 3, 4, 5, 6, 7, 8, 9};
     auto m                          = M(ks, vs, C(4), A(5));
-    std::pair<int, char> expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+    std::pair<int, char> expected[] = {
+        {1, static_cast<char>(1)},
+        {1, static_cast<char>(2)},
+        {1, static_cast<char>(3)},
+        {2, static_cast<char>(4)},
+        {2, static_cast<char>(5)},
+        {2, static_cast<char>(7)},
+        {3, static_cast<char>(6)},
+        {3, static_cast<char>(8)},
+        {3, static_cast<char>(9)}};
     assert(std::ranges::equal(m, expected));
     assert(m.key_comp() == C(4));
     assert(m.keys().get_allocator() == A(5));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/copy_assign.pass.cpp
index 3dd7ebdd38871..8a66a74690fe4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/copy_assign.pass.cpp
@@ -29,7 +29,9 @@ int main(int, char**) {
     std::vector<char, test_allocator<char>> vs({1, 2, 3, 4, 5}, test_allocator<char>(7));
     using M = std::flat_multimap<int, char, 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));
+    auto m  = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+               C(3),
+               test_allocator<int>(2));
     m       = mo;
 
     assert(m.key_comp() == C(5));
@@ -54,7 +56,9 @@ int main(int, char**) {
     auto vs  = Vs({2, 1, 3, 2, 1}, other_allocator<char>(7));
     using M  = std::flat_multimap<int, char, 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));
+    auto m   = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+               C(3),
+               other_allocator<int>(2));
     m        = mo;
 
     assert(m.key_comp() == C(5));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.pass.cpp
index a718d9cfad5b7..152786dc3b337 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.pass.cpp
@@ -31,19 +31,21 @@ using PC = std::pair<const int, long>;
 
 void test_copy() {
   {
-    std::flat_multimap<long, short> source = {{1, 2}, {1, 3}};
+    std::flat_multimap<long, short> source = {{1, static_cast<short>(2)}, {1, static_cast<short>(3)}};
     std::flat_multimap s(source);
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
   }
   {
-    std::flat_multimap<long, short, std::greater<long>> source = {{1, 2}, {1, 3}};
+    std::flat_multimap<long, short, std::greater<long>> source = {
+        {1, static_cast<short>(2)}, {1, static_cast<short>(3)}};
     std::flat_multimap s{source}; // braces instead of parens
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
   }
   {
-    std::flat_multimap<long, short, std::greater<long>> source = {{1, 2}, {1, 3}};
+    std::flat_multimap<long, short, std::greater<long>> source = {
+        {1, static_cast<short>(2)}, {1, static_cast<short>(3)}};
     std::flat_multimap s(source, std::allocator<int>());
     ASSERT_SAME_TYPE(decltype(s), decltype(source));
     assert(s == source);
@@ -55,7 +57,14 @@ void test_containers() {
   std::deque<short, test_allocator<short>> vs({1, 2, 3, 4, 5, 3, 4}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({1, 1, 2, 2, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
   std::deque<short, test_allocator<short>> sorted_vs({1, 3, 2, 4, 5, 4, 3}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{1, 1}, {1, 3}, {2, 2}, {2, 4}, {2, 5}, {3, 4}, {INT_MAX, 3}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(2)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(4)},
+      {INT_MAX, static_cast<short>(3)}};
   {
     std::flat_multimap s(ks, vs);
 
@@ -95,7 +104,14 @@ void test_containers_compare() {
   std::deque<short, test_allocator<short>> vs({1, 2, 3, 4, 5, 3, 4}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 2, 2, 1, 1}, test_allocator<int>(0, 42));
   std::deque<short, test_allocator<short>> sorted_vs({3, 4, 2, 4, 5, 1, 3}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{INT_MAX, 3}, {3, 4}, {2, 2}, {2, 4}, {2, 5}, {1, 1}, {1, 3}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(3)},
+      {3, static_cast<short>(4)},
+      {2, static_cast<short>(2)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(3)}};
   {
     std::flat_multimap s(ks, vs, std::greater<int>());
 
@@ -280,8 +296,18 @@ 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}, {1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
+  std::list<std::pair<int, short>> r = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)},
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {3, static_cast<short>(5)},
+      {INT_MAX, static_cast<short>(4)}};
   {
     std::flat_multimap s(std::from_range, r);
     ASSERT_SAME_TYPE(decltype(s), std::flat_multimap<int, short, std::less<int>>);
@@ -303,8 +329,18 @@ 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}, {1, 1}};
+  std::list<std::pair<int, short>> r = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)},
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(4)},
+      {3, static_cast<short>(5)},
+      {2, static_cast<short>(2)},
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(1)}};
   {
     std::flat_multimap s(std::from_range, r, std::greater<int>());
     ASSERT_SAME_TYPE(decltype(s), std::flat_multimap<int, short, std::greater<int>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct_pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct_pmr.pass.cpp
index 1955a8806631b..c775f937a3890 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct_pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct_pmr.pass.cpp
@@ -35,7 +35,14 @@ void test_containers() {
   std::deque<short, test_allocator<short>> vs({1, 2, 3, 4, 5, 3, 4}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({1, 1, 2, 2, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
   std::deque<short, test_allocator<short>> sorted_vs({1, 3, 2, 4, 5, 4, 3}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{1, 1}, {1, 3}, {2, 2}, {2, 4}, {2, 5}, {3, 4}, {INT_MAX, 3}};
+  const std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(2)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(4)},
+      {INT_MAX, static_cast<short>(3)}};
   {
     std::pmr::monotonic_buffer_resource mr;
     std::pmr::monotonic_buffer_resource mr2;
@@ -69,7 +76,14 @@ void test_containers_compare() {
   std::deque<short, test_allocator<short>> vs({1, 2, 3, 4, 5, 3, 4}, test_allocator<int>(0, 43));
   std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 2, 2, 1, 1}, test_allocator<int>(0, 42));
   std::deque<short, test_allocator<short>> sorted_vs({3, 4, 2, 4, 5, 1, 3}, test_allocator<int>(0, 43));
-  const std::pair<int, short> expected[] = {{INT_MAX, 3}, {3, 4}, {2, 2}, {2, 4}, {2, 5}, {1, 1}, {1, 3}};
+  const std::pair<int, short> expected[] = {
+      {INT_MAX, static_cast<short>(3)},
+      {3, static_cast<short>(4)},
+      {2, static_cast<short>(2)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(3)}};
 
   {
     std::pmr::monotonic_buffer_resource mr;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/initializer_list.pass.cpp
index 8e89192ec0ea1..f81a9ebdfc87f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/initializer_list.pass.cpp
@@ -83,11 +83,23 @@ int main(int, char**) {
         !std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, std::allocator<int>>);
   }
 
-  std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {2, 2}, {3, 3}, {3, 3}, {5, 2}};
+  std::pair<int, short> expected[] = {
+      {1, static_cast<short>(1)},
+      {2, static_cast<short>(2)},
+      {2, static_cast<short>(2)},
+      {3, static_cast<short>(3)},
+      {3, static_cast<short>(3)},
+      {5, static_cast<short>(2)}};
   {
     // flat_multimap(initializer_list<value_type>);
     using M                                         = std::flat_multimap<int, short>;
-    std::initializer_list<std::pair<int, short>> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    std::initializer_list<std::pair<int, short>> il = {
+        {5, static_cast<short>(2)},
+        {2, static_cast<short>(2)},
+        {2, static_cast<short>(2)},
+        {3, static_cast<short>(3)},
+        {1, static_cast<short>(1)},
+        {3, static_cast<short>(3)}};
     M m(il);
     assert(std::ranges::equal(m, expected));
   }
@@ -95,13 +107,23 @@ int main(int, char**) {
     // flat_multimap(initializer_list<value_type>);
     // explicit(false)
     using M = std::flat_multimap<int, short>;
-    M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    M m     = {{5, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {3, static_cast<short>(3)},
+               {1, static_cast<short>(1)},
+               {3, static_cast<short>(3)}};
     assert(std::ranges::equal(m, expected));
   }
   {
     // flat_multimap(initializer_list<value_type>);
     using M = std::flat_multimap<int, short, std::greater<int>, std::deque<int, min_allocator<int>>>;
-    M m     = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+    M m     = {{5, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {2, static_cast<short>(2)},
+               {3, static_cast<short>(3)},
+               {1, static_cast<short>(1)},
+               {3, static_cast<short>(3)}};
     assert(std::equal(m.rbegin(), m.rend(), expected, expected + 6));
   }
   {
@@ -129,12 +151,25 @@ int main(int, char**) {
     // flat_multimap(initializer_list<value_type>, const key_compare&);
     using C = test_less<int>;
     using M = std::flat_multimap<int, short, C>;
-    auto m  = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10));
+    auto m =
+        M({{5, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {3, static_cast<short>(3)},
+           {1, static_cast<short>(1)},
+           {3, static_cast<short>(3)}},
+          C(10));
     assert(std::ranges::equal(m, expected));
     assert(m.key_comp() == C(10));
 
     // explicit(false)
-    M m2 = {{{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10)};
+    M m2 = {{{5, static_cast<short>(2)},
+             {2, static_cast<short>(2)},
+             {2, static_cast<short>(2)},
+             {3, static_cast<short>(3)},
+             {1, static_cast<short>(1)},
+             {3, static_cast<short>(3)}},
+            C(10)};
     assert(m2 == m);
     assert(m2.key_comp() == C(10));
   }
@@ -142,7 +177,14 @@ int main(int, char**) {
     // flat_multimap(initializer_list<value_type>, const key_compare&);
     // Sorting uses the comparator that was passed in
     using M = std::flat_multimap<int, short, std::function<bool(int, int)>, std::deque<int, min_allocator<int>>>;
-    auto m  = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, std::greater<int>());
+    auto m =
+        M({{5, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {2, static_cast<short>(2)},
+           {3, static_cast<short>(3)},
+           {1, static_cast<short>(1)},
+           {3, static_cast<short>(3)}},
+          std::greater<int>());
     assert(std::equal(m.rbegin(), m.rend(), expected, expected + 6));
     assert(m.key_comp()(2, 1) == true);
   }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter.pass.cpp
index c9c5e6c99d1c8..25c0cf04aaed6 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter.pass.cpp
@@ -57,9 +57,27 @@ int main(int, char**) {
     static_assert(!std::is_constructible_v<M3, Iter3, Iter3, const C&, const A2&>);
   }
 
-  using P      = std::pair<int, short>;
-  P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-  P expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+  using P = std::pair<int, short>;
+  P ar[]  = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(6)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
+  P expected[] = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(6)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
   {
     // flat_multimap(InputIterator , InputIterator)
     // cpp17_input_iterator
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign.pass.cpp
index 38200d008c78a..b033e5f3948cc 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign.pass.cpp
@@ -32,7 +32,7 @@ int main(int, char**) {
     using A1 = test_allocator<int>;
     using A2 = test_allocator<char>;
     using M  = std::flat_multimap<int, char, C, std::vector<int, A1>, std::vector<char, A2>>;
-    M mo     = M({{1, 1}, {1, 3}, {3, 2}}, C(5), A1(7));
+    M mo     = M({{1, static_cast<char>(1)}, {1, static_cast<char>(3)}, {3, static_cast<char>(2)}}, C(5), A1(7));
     M m      = M({}, C(3), A1(7));
     m        = std::move(mo);
     assert((m == M{{1, 1}, {1, 3}, {3, 2}}));
@@ -47,8 +47,13 @@ int main(int, char**) {
     using A1 = other_allocator<int>;
     using A2 = other_allocator<char>;
     using M  = std::flat_multimap<int, char, C, std::deque<int, A1>, std::deque<char, A2>>;
-    M mo     = M({{4, 5}, {4, 4}}, C(5), A1(7));
-    M m      = M({{1, 1}, {1, 2}, {1, 3}, {4, 4}}, C(3), A1(7));
+    M mo     = M({{4, static_cast<char>(5)}, {4, static_cast<char>(4)}}, C(5), A1(7));
+    M m      = M({{1, static_cast<char>(1)}, //
+                  {1, static_cast<char>(2)},
+                  {1, static_cast<char>(3)},
+                  {4, static_cast<char>(4)}},
+            C(3),
+            A1(7));
     m        = std::move(mo);
     assert((m == M{{4, 5}, {4, 4}}));
     assert(m.key_comp() == C(5));
@@ -60,8 +65,12 @@ int main(int, char**) {
   {
     using A = min_allocator<int>;
     using M = std::flat_multimap<int, int, std::greater<int>, std::vector<int, A>, std::vector<int, A>>;
-    M mo    = M({{5, 1}, {5, 2}, {3, 3}}, A());
-    M m     = M({{4, 4}, {4, 3}, {4, 2}, {1, 1}}, A());
+    M mo    = M({{5, static_cast<char>(1)}, {5, static_cast<char>(2)}, {3, static_cast<char>(3)}}, A());
+    M m     = M({{4, static_cast<char>(4)}, //
+                 {4, static_cast<char>(3)},
+                 {4, static_cast<char>(2)},
+                 {1, static_cast<char>(1)}},
+            A());
     m       = std::move(mo);
     assert((m == M{{5, 1}, {5, 2}, {3, 3}}));
     auto [ks, vs] = std::move(m).extract();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/pmr.pass.cpp
index 8b518f6afbda9..c6c8a10cafc5a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/pmr.pass.cpp
@@ -166,9 +166,27 @@ int main(int, char**) {
   }
   {
     // flat_multimap(InputIterator first, InputIterator last, const Allocator& a);
-    using P      = std::pair<int, short>;
-    P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-    P expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+    using P = std::pair<int, short>;
+    P ar[]  = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {3, static_cast<short>(6)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
+    P expected[] = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(6)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
     {
       //  cpp17 iterator
       using M = std::flat_multimap<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
@@ -242,9 +260,27 @@ int main(int, char**) {
   }
   {
     //  flat_multimap(from_range_t, R&&, const Alloc&);
-    using P      = std::pair<int, short>;
-    P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-    P expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+    using P = std::pair<int, short>;
+    P ar[]  = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {3, static_cast<short>(6)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
+    P expected[] = {
+        {1, static_cast<short>(1)},
+        {1, static_cast<short>(2)},
+        {1, static_cast<short>(3)},
+        {2, static_cast<short>(4)},
+        {2, static_cast<short>(5)},
+        {2, static_cast<short>(7)},
+        {3, static_cast<short>(6)},
+        {3, static_cast<short>(8)},
+        {3, static_cast<short>(9)}};
     {
       // input_range
       using M    = std::flat_multimap<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/range.pass.cpp
index de750e2506341..d5e380dbfcd4d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/range.pass.cpp
@@ -117,9 +117,27 @@ int main(int, char**) {
     static_assert(!std::is_constructible_v<M, std::from_range_t, std::vector<NonPairLike>&, const C&, const A1&>);
   }
 
-  using P      = std::pair<int, short>;
-  P ar[]       = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
-  P expected[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {2, 7}, {3, 6}, {3, 8}, {3, 9}};
+  using P = std::pair<int, short>;
+  P ar[]  = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {3, static_cast<short>(6)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
+  P expected[] = {
+      {1, static_cast<short>(1)},
+      {1, static_cast<short>(2)},
+      {1, static_cast<short>(3)},
+      {2, static_cast<short>(4)},
+      {2, static_cast<short>(5)},
+      {2, static_cast<short>(7)},
+      {3, static_cast<short>(6)},
+      {3, static_cast<short>(8)},
+      {3, static_cast<short>(9)}};
   {
     // flat_multimap(from_range_t, R&&)
     // input_range && !common
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_container.pass.cpp
index 16579f0deed5d..4534d5d0d249d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_container.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_container.pass.cpp
@@ -66,11 +66,17 @@ int main(int, char**) {
     auto vs2             = vs;
 
     auto m = M(std::sorted_equivalent, ks, vs);
-    assert((m == M{{1, 4}, {4, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {4, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
     m = M(std::sorted_equivalent, std::move(ks), std::move(vs));
     assert(ks.empty()); // it was moved-from
     assert(vs.empty()); // it was moved-from
-    assert((m == M{{1, 4}, {4, 3}, {4, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {4, static_cast<char>(3)},
+                   {4, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
 
     // explicit(false)
     M m2 = {std::sorted_equivalent, std::move(ks2), std::move(vs2)};
@@ -85,7 +91,10 @@ int main(int, char**) {
     Ks ks    = {10, 1, 1, 1};
     Vs vs    = {1, 2, 3, 4};
     auto m   = M(std::sorted_equivalent, ks, vs);
-    assert((m == M{{1, 2}, {1, 3}, {1, 4}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(2)},
+                   {1, static_cast<char>(3)},
+                   {1, static_cast<char>(4)},
+                   {10, static_cast<char>(1)}}));
     m = M(std::sorted_equivalent, std::move(ks), std::move(vs));
     assert(ks.empty()); // it was moved-from
     assert(vs.empty()); // it was moved-from
@@ -113,7 +122,10 @@ int main(int, char**) {
     std::vector<char> vs = {4, 3, 2, 1};
 
     auto m = M(std::sorted_equivalent, ks, vs, C(4));
-    assert((m == M{{1, 4}, {2, 3}, {10, 2}, {10, 1}}));
+    assert((m == M{{1, static_cast<char>(4)},
+                   {2, static_cast<char>(3)},
+                   {10, static_cast<char>(2)},
+                   {10, static_cast<char>(1)}}));
     assert(m.key_comp() == C(4));
 
     // explicit(false)
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_initializer_list.pass.cpp
index b34313bb3d404..c33a259acd5e5 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_initializer_list.pass.cpp
@@ -31,7 +31,11 @@
 #include "../../../test_compare.h"
 
 template <class T, class U>
-std::initializer_list<std::pair<T, U>> il = {{1, 1}, {4, 2}, {4, 4}, {5, 5}};
+std::initializer_list<std::pair<T, U>> il = {
+    {static_cast<T>(1), static_cast<U>(1)},
+    {static_cast<T>(4), static_cast<U>(2)},
+    {static_cast<T>(4), static_cast<U>(4)},
+    {static_cast<T>(5), static_cast<U>(5)}};
 
 const auto il1 = il<int, int>;
 const auto il2 = il<int, short>;
@@ -144,7 +148,8 @@ int main(int, char**) {
     using A2      = test_allocator<short>;
     using M       = std::flat_multimap<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
     auto m        = M(std::sorted_equivalent, il2, A1(5));
-    auto expected = M{{1, 1}, {4, 2}, {4, 4}, {5, 5}};
+    auto expected = M{
+        {1, static_cast<short>(1)}, {4, static_cast<short>(2)}, {4, static_cast<short>(4)}, {5, static_cast<short>(5)}};
     assert(m == expected);
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -162,7 +167,10 @@ int main(int, char**) {
     using A2 = test_allocator<short>;
     using M  = std::flat_multimap<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
     auto m   = M(std::sorted_equivalent, il2, C(3), A1(5));
-    assert((m == M{{1, 1}, {4, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{1, static_cast<short>(1)},
+                   {4, static_cast<short>(2)},
+                   {4, static_cast<short>(4)},
+                   {5, static_cast<short>(5)}}));
     assert(m.key_comp() == C(3));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -174,7 +182,10 @@ int main(int, char**) {
     using A2 = test_allocator<int>;
     using M  = std::flat_multimap<short, int, std::less<int>, std::deque<short, A1>, std::vector<int, A2>>;
     M m      = {std::sorted_equivalent, il3, {}, A1(5)}; // implicit ctor
-    assert((m == M{{1, 1}, {4, 2}, {4, 4}, {5, 5}}));
+    assert((m == M{{static_cast<short>(1), 1},
+                   {static_cast<short>(4), 2},
+                   {static_cast<short>(4), 4},
+                   {static_cast<short>(5), 5}}));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
   }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_iter_iter.pass.cpp
index 45c4b3dc675a5..bd96fa91bc65f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/sorted_iter_iter.pass.cpp
@@ -130,7 +130,8 @@ int main(int, char**) {
     using P       = std::pair<int, int>;
     P ar[]        = {{2, 1}, {2, 2}, {4, 4}, {5, 5}};
     auto m        = M(std::sorted_equivalent, ar, ar + 4, A1(5));
-    auto expected = M{{2, 1}, {2, 2}, {4, 4}, {5, 5}};
+    auto expected = M{
+        {2, static_cast<short>(1)}, {2, static_cast<short>(2)}, {4, static_cast<short>(4)}, {5, static_cast<short>(5)}};
     assert(m == expected);
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -150,7 +151,10 @@ int main(int, char**) {
     using P  = std::pair<int, int>;
     P ar[]   = {{1, 1}, {1, 2}, {1, 4}, {1, 5}};
     auto m   = M(std::sorted_equivalent, ar, ar + 4, C(3), A1(5));
-    assert((m == M{{1, 1}, {1, 2}, {1, 4}, {1, 5}}));
+    assert((m == M{{1, static_cast<short>(1)},
+                   {1, static_cast<short>(2)},
+                   {1, static_cast<short>(4)},
+                   {1, static_cast<short>(5)}}));
     assert(m.key_comp() == C(3));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
@@ -162,8 +166,9 @@ int main(int, char**) {
     using A2 = test_allocator<int>;
     using M  = std::flat_multimap<short, int, std::less<int>, std::deque<short, A1>, std::vector<int, A2>>;
     using P  = std::pair<int, int>;
-    P ar[]   = {{1, 1}, {1, 2}, {1, 4}, {1, 5}};
-    M m      = {std::sorted_equivalent, ar, ar + 4, {}, A1(5)}; // implicit ctor
+    P ar[]   = {
+        {static_cast<short>(1), 1}, {static_cast<short>(1), 2}, {static_cast<short>(1), 4}, {static_cast<short>(1), 5}};
+    M m = {std::sorted_equivalent, ar, ar + 4, {}, A1(5)}; // implicit ctor
     assert((m == M{{1, 1}, {1, 2}, {1, 4}, {1, 5}}));
     assert(m.keys().get_allocator() == A1(5));
     assert(m.values().get_allocator() == A2(5));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp
index 13b57202f7862..95f7e11626a4e 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp
@@ -68,7 +68,8 @@ struct ErasurePredicate {
 };
 
 int main(int, char**) {
-  const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+  [[maybe_unused]] const std::pair<int, int> expected[] = {
+      {1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
   {
     using M = std::flat_multimap<ThrowingAssignment, int, ThrowingComparator>;
     for (int first_throw = 1; first_throw < 99; ++first_throw) {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/erase_key.pass.cpp
index 7944996fba1a0..b9624d45a8041 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/erase_key.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/erase_key.pass.cpp
@@ -34,7 +34,7 @@ void test() {
   auto make = [](std::initializer_list<int> il) {
     M m;
     for (int i : il) {
-      m.emplace(i, i);
+      m.emplace(i, static_cast<char>(i));
     }
     return m;
   };



More information about the libcxx-commits mailing list