Skip to content

Commit eadd3be

Browse files
Dev11_0000000_null_forward_iterators: Avoid Clang warnings, guard headers for C++17/20 (#5654)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent a0168f1 commit eadd3be

File tree

1 file changed

+15
-9
lines changed
  • tests/std/tests/Dev11_0000000_null_forward_iterators

1 file changed

+15
-9
lines changed

tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING
54
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
65
#define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
76

@@ -10,21 +9,28 @@
109
#include <cstring>
1110
#include <deque>
1211
#include <experimental/filesystem>
13-
#include <filesystem>
1412
#include <forward_list>
1513
#include <iterator>
1614
#include <list>
1715
#include <map>
1816
#include <new>
1917
#include <regex>
2018
#include <set>
21-
#include <span>
2219
#include <string>
2320
#include <type_traits>
2421
#include <unordered_map>
2522
#include <unordered_set>
2623
#include <vector>
2724

25+
#if _HAS_CXX17
26+
#include <filesystem>
27+
#include <string_view>
28+
#endif // _HAS_CXX17
29+
30+
#if _HAS_CXX20
31+
#include <span>
32+
#endif // _HAS_CXX20
33+
2834
using namespace std;
2935

3036
// N3797 24.2.5 [forward.iterators]/2:
@@ -91,14 +97,14 @@ void test_iterator() {
9197
}
9298

9399
{
94-
aligned_union_t<0, FwdIt> au3;
95-
aligned_union_t<0, FwdIt> au4;
100+
alignas(FwdIt) unsigned char buf3[sizeof(FwdIt)];
101+
alignas(FwdIt) unsigned char buf4[sizeof(FwdIt)];
96102

97-
FwdIt* p3 = reinterpret_cast<FwdIt*>(&au3);
98-
FwdIt* p4 = reinterpret_cast<FwdIt*>(&au4);
103+
memset(buf3, 0xCC, sizeof(FwdIt));
104+
memset(buf4, 0xDD, sizeof(FwdIt));
99105

100-
memset(p3, 0xCC, sizeof(FwdIt));
101-
memset(p4, 0xDD, sizeof(FwdIt));
106+
FwdIt* p3 = reinterpret_cast<FwdIt*>(buf3);
107+
FwdIt* p4 = reinterpret_cast<FwdIt*>(buf4);
102108

103109
new (p3) FwdIt{};
104110
new (p4) FwdIt{};

0 commit comments

Comments
 (0)