Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STL Hardening #5274

Merged
merged 42 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7d01c7c
Exclude valarray's 28 binary ops, no test impact.
StephanTLavavej Jan 27, 2025
96471c5
Exclude condition_variable::wait_until, no test impact.
StephanTLavavej Jan 27, 2025
809bbee
Exclude basic_string::resize_and_overwrite, no test impact.
StephanTLavavej Jan 27, 2025
bd4e2ba
Exclude basic_string_view's ctor, update test coverage.
StephanTLavavej Jan 27, 2025
1f933a7
Exclude span::size_bytes, update test coverage.
StephanTLavavej Jan 27, 2025
a96d50b
Exclude most of `<mdspan>`, update test coverage.
StephanTLavavej Jan 28, 2025
4da1340
Exclude `<generator>`, update test coverage.
StephanTLavavej Jan 27, 2025
1acddc8
Exclude iota_view, update test coverage.
StephanTLavavej Jan 27, 2025
818163a
Exclude repeat_view, update test coverage.
StephanTLavavej Jan 27, 2025
03d1405
Exclude filter_view, update test coverage.
StephanTLavavej Jan 27, 2025
7d52a23
Exclude take_view, update test coverage.
StephanTLavavej Jan 27, 2025
6c79b36
Exclude take_while_view, update test coverage.
StephanTLavavej Jan 27, 2025
ad023f9
Exclude drop_view, update test coverage.
StephanTLavavej Jan 27, 2025
4a87616
Exclude drop_while_view, update test coverage.
StephanTLavavej Jan 27, 2025
9ef4d62
Exclude views::counted, update test coverage.
StephanTLavavej Jan 27, 2025
65d99ec
Exclude chunk_view, update test coverage.
StephanTLavavej Jan 27, 2025
311d174
Exclude slide_view, update test coverage.
StephanTLavavej Jan 27, 2025
40ea373
Exclude chunk_by_view, update test coverage.
StephanTLavavej Jan 27, 2025
705b096
Exclude stride_view, update test coverage.
StephanTLavavej Jan 27, 2025
e21a1ae
Exclude cartesian_product_view, update test coverage.
StephanTLavavej Jan 27, 2025
19e8406
Add `_MSVC_STL_HARDENING` control macros, initially off-by-default.
StephanTLavavej Jan 27, 2025
777f8ee
Harden array.
StephanTLavavej Jan 29, 2025
8b7ba64
Harden deque, overhaul pop_front/pop_back.
StephanTLavavej Jan 29, 2025
f1d8fe7
Harden forward_list, add pop_front.
StephanTLavavej Jan 29, 2025
c9ceb7e
Harden list.
StephanTLavavej Jan 29, 2025
d5a39a1
Harden vector, add vector<bool>::pop_back.
StephanTLavavej Jan 29, 2025
2c2a79e
Harden basic_string, add pop_back.
StephanTLavavej Jan 29, 2025
c65c68b
Harden basic_string_view.
StephanTLavavej Jan 29, 2025
0a799fb
Harden span.
StephanTLavavej Jan 30, 2025
78e097b
Harden mdspan.
StephanTLavavej Jan 30, 2025
9275943
Harden expected.
StephanTLavavej Jan 30, 2025
95355d4
Harden optional.
StephanTLavavej Jan 30, 2025
0b6c641
Harden valarray.
StephanTLavavej Jan 30, 2025
274a0bd
Harden ranges::view_interface.
StephanTLavavej Jan 30, 2025
e26df58
Harden bitset, overhauling operator[].
StephanTLavavej Jan 30, 2025
77b6fc5
Update test coverage for CDL removal.
StephanTLavavej Feb 5, 2025
9c8a7b1
Remove CDL's default definition and emit an error if users define it.
StephanTLavavej Feb 1, 2025
33c69b1
Add test coverage: GH_005090_stl_hardening
StephanTLavavej Feb 2, 2025
fae0a97
Enhancement: Move span::size_bytes() debug checks into span's ctors.
StephanTLavavej Feb 6, 2025
199fffd
Enhancement: Overhaul the STL's "doom function".
StephanTLavavej Feb 6, 2025
cc35a7b
Code review feedback: Improve comments and debug messages.
StephanTLavavej Feb 13, 2025
175f14d
Pre-emptively resolve conflict with GH 5274 by marking bitset.members…
StephanTLavavej Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 50 additions & 50 deletions stl/inc/mdspan

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions tests/std/tests/P0009R18_mdspan_extents_death/test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define _CONTAINER_DEBUG_LEVEL 1

#include <array>
#include <cstddef>
#include <mdspan>
Expand Down Expand Up @@ -97,6 +95,8 @@ void test_construction_from_array_with_unrepresentable_as_index_type_values() {

int main(int argc, char* argv[]) {
std_testing::death_test_executive exec;

#if _ITERATOR_DEBUG_LEVEL != 0
exec.add_death_tests({
test_static_extent_function_with_invalid_index,
test_extent_function_with_invalid_index,
Expand All @@ -111,5 +111,7 @@ int main(int argc, char* argv[]) {
test_construction_from_array_with_invalid_values,
test_construction_from_array_with_unrepresentable_as_index_type_values,
});
#endif // _ITERATOR_DEBUG_LEVEL != 0

return exec.run(argc, argv);
}
8 changes: 5 additions & 3 deletions tests/std/tests/P0009R18_mdspan_layout_left_death/test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define _CONTAINER_DEBUG_LEVEL 1

#include <array>
#include <cstddef>
#include <mdspan>
Expand Down Expand Up @@ -41,7 +39,7 @@ void test_construction_from_other_stride_mapping_1() {
layout_stride::mapping<Ext> m1{Ext{}, array{4, 1}};
// For all r in the range [0, extents_type::rank()), other.stride(r) must be equal to
// extents().fwd-prod-of-extents(r)
layout_left::mapping<Ext> m2{m1};
[[maybe_unused]] layout_left::mapping<Ext> m2{m1};
}

void test_construction_from_other_stride_mapping_2() {
Expand All @@ -67,6 +65,8 @@ void test_stride_function() {

int main(int argc, char* argv[]) {
std_testing::death_test_executive exec;

#if _ITERATOR_DEBUG_LEVEL != 0
exec.add_death_tests({
test_construction_from_extents_type_with_signed_index_type,
test_construction_from_extents_type_with_unsigned_index_type,
Expand All @@ -77,5 +77,7 @@ int main(int argc, char* argv[]) {
test_call_operator,
test_stride_function,
});
#endif // _ITERATOR_DEBUG_LEVEL != 0

return exec.run(argc, argv);
}
8 changes: 5 additions & 3 deletions tests/std/tests/P0009R18_mdspan_layout_right_death/test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define _CONTAINER_DEBUG_LEVEL 1

#include <array>
#include <cstddef>
#include <mdspan>
Expand Down Expand Up @@ -41,7 +39,7 @@ void test_construction_from_other_stride_mapping_1() {
layout_stride::mapping<Ext> m1{Ext{}, array{1, 2}};
// For all r in the range [0, extents_type::rank()), other.stride(r) must be equal to
// extents().rev-prod-of-extents(r)
layout_right::mapping<Ext> m2{m1};
[[maybe_unused]] layout_right::mapping<Ext> m2{m1};
}

void test_construction_from_other_stride_mapping_2() {
Expand All @@ -67,6 +65,8 @@ void test_stride_function() {

int main(int argc, char* argv[]) {
std_testing::death_test_executive exec;

#if _ITERATOR_DEBUG_LEVEL != 0
exec.add_death_tests({
test_construction_from_extents_type_with_signed_index_type,
test_construction_from_extents_type_with_unsigned_index_type,
Expand All @@ -77,5 +77,7 @@ int main(int argc, char* argv[]) {
test_call_operator,
test_stride_function,
});
#endif // _ITERATOR_DEBUG_LEVEL != 0

return exec.run(argc, argv);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define _CONTAINER_DEBUG_LEVEL 1

#include <array>
#include <cstddef>
#include <mdspan>
Expand Down Expand Up @@ -69,6 +67,8 @@ void test_stride_with_empty_extents() {

int main(int argc, char* argv[]) {
std_testing::death_test_executive exec;

#if _ITERATOR_DEBUG_LEVEL != 0
exec.add_death_tests({
test_default_construction,
test_construction_from_extents_and_array_1,
Expand All @@ -79,5 +79,7 @@ int main(int argc, char* argv[]) {
test_call_operator,
test_stride_with_empty_extents,
});
#endif // _ITERATOR_DEBUG_LEVEL != 0

return exec.run(argc, argv);
}
15 changes: 12 additions & 3 deletions tests/std/tests/P0009R18_mdspan_mdspan_death/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,25 @@ void test_size_when_index_type_is_unsigned() {

int main(int argc, char* argv[]) {
std_testing::death_test_executive exec;

#if _ITERATOR_DEBUG_LEVEL != 0
exec.add_death_tests({
test_construction_from_other_mdspan,
#ifdef __cpp_multidimensional_subscript // TRANSITION, P2128R6
test_access_with_invalid_multidimensional_index_1,
test_access_with_nonrepresentable_index_1,
#endif // __cpp_multidimensional_subscript
test_access_with_invalid_multidimensional_index_2,
test_access_with_nonrepresentable_index_2,
test_size_when_index_type_is_signed,
test_size_when_index_type_is_unsigned,
});
#endif // _ITERATOR_DEBUG_LEVEL != 0

exec.add_death_tests({
test_construction_from_other_mdspan,
#ifdef __cpp_multidimensional_subscript // TRANSITION, P2128R6
test_access_with_invalid_multidimensional_index_1,
#endif // __cpp_multidimensional_subscript
test_access_with_invalid_multidimensional_index_2,
});

return exec.run(argc, argv);
}