Skip to content

Commit 2019761

Browse files
committed
Intentionally invokes standard std::equal in fill, fill_n tests
1 parent 1a155fe commit 2019761

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,24 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
5555
std::vector<bool, Alloc> in(100, false, Alloc(1));
5656
std::vector<bool, Alloc> expected(100, true, Alloc(1));
5757
std::fill(in.begin(), in.end(), true);
58-
assert(in == expected);
58+
59+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
60+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
61+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
62+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
63+
// assert(in == expected);
5964
}
6065
{
6166
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
6267
std::vector<bool, Alloc> in(200, false, Alloc(1));
6368
std::vector<bool, Alloc> expected(200, true, Alloc(1));
6469
std::fill(in.begin(), in.end(), true);
65-
assert(in == expected);
70+
71+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
72+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
73+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
74+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
75+
// assert(in == expected);
6676
}
6777
{
6878
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,24 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
137137
std::vector<bool, Alloc> in(100, false, Alloc(1));
138138
std::vector<bool, Alloc> expected(100, true, Alloc(1));
139139
std::fill_n(in.begin(), in.size(), true);
140-
assert(in == expected);
140+
141+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
142+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
143+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
144+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
145+
// assert(in == expected);
141146
}
142147
{
143148
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
144149
std::vector<bool, Alloc> in(200, false, Alloc(1));
145150
std::vector<bool, Alloc> expected(200, true, Alloc(1));
146151
std::fill_n(in.begin(), in.size(), true);
147-
assert(in == expected);
152+
153+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
154+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
155+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
156+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
157+
// assert(in == expected);
148158
}
149159
{
150160
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill.pass.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,24 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
9191
std::vector<bool, Alloc> in(100, false, Alloc(1));
9292
std::vector<bool, Alloc> expected(100, true, Alloc(1));
9393
std::ranges::fill(in, true);
94-
assert(in == expected);
94+
95+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
96+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
97+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
98+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
99+
// assert(in == expected);
95100
}
96101
{
97102
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
98103
std::vector<bool, Alloc> in(200, false, Alloc(1));
99104
std::vector<bool, Alloc> expected(200, true, Alloc(1));
100105
std::ranges::fill(in, true);
101-
assert(in == expected);
106+
107+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
108+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
109+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
110+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
111+
// assert(in == expected);
102112
}
103113
{
104114
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill_n.pass.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,24 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
6464
std::vector<bool, Alloc> in(100, false, Alloc(1));
6565
std::vector<bool, Alloc> expected(100, true, Alloc(1));
6666
std::ranges::fill_n(std::ranges::begin(in), in.size(), true);
67-
assert(in == expected);
67+
68+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
69+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
70+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
71+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
72+
// assert(in == expected);
6873
}
6974
{
7075
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
7176
std::vector<bool, Alloc> in(200, false, Alloc(1));
7277
std::vector<bool, Alloc> expected(200, true, Alloc(1));
7378
std::ranges::fill_n(std::ranges::begin(in), in.size(), true);
74-
assert(in == expected);
79+
80+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
81+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
82+
using It = cpp17_input_iterator<std::vector<bool, Alloc>::iterator>;
83+
assert(in.size() == expected.size() && std::equal(It(in.begin()), It(in.end()), It(expected.begin())));
84+
// assert(in == expected);
7585
}
7686
{
7787
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

0 commit comments

Comments
 (0)