Skip to content

Commit a6c2a72

Browse files
Silence warning C4324: structure was padded due to alignment specifier (#4426)
Co-authored-by: Alex Guteniev <[email protected]>
1 parent 2a052a6 commit a6c2a72

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

stl/inc/execution

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,6 @@ struct alignas(_Ty) alignas(size_t) alignas(_Atomic_counter_t) _Circular_buffer
571571
}
572572
};
573573

574-
#pragma warning(push)
575-
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
576574
template <class _Ty>
577575
class alignas(hardware_destructive_interference_size) _Work_stealing_deque {
578576
// thread-local work-stealing deque, which allows efficient access from a single owner thread at the "bottom"
@@ -686,7 +684,6 @@ private:
686684
_Guarded_by_(_Segment_lock) _Circular_buffer<_Ty>* _Segment{_Circular_buffer<_Ty>::_New_circular_buffer()};
687685
mutex _Segment_lock{};
688686
};
689-
#pragma warning(pop)
690687

691688
enum class _Steal_result { _Success, _Abort, _Done };
692689

@@ -2524,13 +2521,10 @@ struct _Static_partitioned_remove_if2 {
25242521
// may transition from _Serial directly to _Done, doing the moving step implicitly.
25252522
};
25262523

2527-
#pragma warning(push)
2528-
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
25292524
struct alignas(hardware_destructive_interference_size) alignas(_FwdIt) _Chunk_local_data {
25302525
atomic<_Chunk_state> _State;
25312526
_FwdIt _New_end;
25322527
};
2533-
#pragma warning(pop)
25342528

25352529
_Static_partition_team<_Iter_diff_t<_FwdIt>> _Team;
25362530
_Static_partition_range<_FwdIt> _Basis;
@@ -3486,14 +3480,11 @@ struct _Static_partitioned_partition2 {
34863480
_Done // when a chunk becomes _Done, it is complete / will never need to touch _Results again
34873481
};
34883482

3489-
#pragma warning(push)
3490-
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
34913483
struct alignas(hardware_destructive_interference_size) alignas(_FwdIt) _Chunk_local_data {
34923484
atomic<_Chunk_state> _State;
34933485
_FwdIt _Beginning_of_falses;
34943486
_Diff _Chunk_trues;
34953487
};
3496-
#pragma warning(pop)
34973488

34983489
_Static_partition_team<_Diff> _Team;
34993490
_Static_partition_range<_FwdIt> _Basis;

stl/inc/xutility

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,10 +3865,6 @@ namespace ranges {
38653865
constexpr explicit _Subrange_base(const _Size_type& _Size_) noexcept : _Size(_Size_) {}
38663866
};
38673867

3868-
#if 1 // TRANSITION, VSO-1695918 - Warning C4324 incorrectly firing in the presence of `pragma pack`
3869-
#pragma warning(push)
3870-
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
3871-
#endif // ^^^ workaround ^^^
38723868
_EXPORT_STD template <input_or_output_iterator _It, sentinel_for<_It> _Se, subrange_kind _Ki>
38733869
requires (_Ki == subrange_kind::sized || !sized_sentinel_for<_Se, _It>)
38743870
class subrange : public _Subrange_base<_It, _Se, _Ki> {
@@ -4032,9 +4028,6 @@ namespace ranges {
40324028
return *this;
40334029
}
40344030
};
4035-
#if 1 // TRANSITION, VSO-1695918 - Warning C4324 incorrectly firing in the presence of `pragma pack`
4036-
#pragma warning(pop)
4037-
#endif // ^^^ workaround ^^^
40384031

40394032
template <input_or_output_iterator _It, sentinel_for<_It> _Se>
40404033
subrange(_It, _Se) -> subrange<_It, _Se>;

stl/inc/yvals_core.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@
778778
#endif // !defined(_STL_EXTRA_DISABLED_WARNINGS)
779779

780780
// warning C4180: qualifier applied to function type has no meaning; ignored
781+
// warning C4324: structure was padded due to alignment specifier
781782
// warning C4412: function signature contains type 'meow'; C++ objects are unsafe to pass between pure code
782783
// and mixed or native. (/Wall)
783784
// warning C4455: literal suffix identifiers that do not start with an underscore are reserved
@@ -809,9 +810,9 @@
809810
#ifndef _STL_DISABLED_WARNINGS
810811
// clang-format off
811812
#define _STL_DISABLED_WARNINGS \
812-
4180 4412 4455 4494 4514 4574 4582 4583 4587 4588 \
813-
4619 4623 4625 4626 4643 4648 4702 4793 4820 4868 \
814-
4988 5026 5027 5045 5220 6294 \
813+
4180 4324 4412 4455 4494 4514 4574 4582 4583 4587 \
814+
4588 4619 4623 4625 4626 4643 4648 4702 4793 4820 \
815+
4868 4988 5026 5027 5045 5220 6294 \
815816
_STL_DISABLED_WARNING_C4577 \
816817
_STL_DISABLED_WARNING_C4984 \
817818
_STL_DISABLED_WARNING_C5053 \

tests/std/tests/P2374R4_views_cartesian_product/test.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,20 @@ constexpr void test_gh_3733() {
934934
assert(as_const(cart).size() == 0);
935935
}
936936

937+
// GH-4425 <ranges>: views::cartesian_product and views::filter emit
938+
// spurious warning C4324 'structure was padded due to alignment specifier'
939+
constexpr void test_gh_4425() {
940+
const vector<int> vec{11, 22, 33, 44};
941+
942+
const auto strictly_ascending = [](const auto& t) { return get<0>(t) < get<1>(t); };
943+
944+
const auto result = ranges::to<vector>(views::cartesian_product(vec, vec) | views::filter(strictly_ascending));
945+
946+
const vector<tuple<int, int>> correct{{11, 22}, {11, 33}, {11, 44}, {22, 33}, {22, 44}, {33, 44}};
947+
948+
assert(result == correct);
949+
}
950+
937951
int main() {
938952
// Check views
939953
#ifndef __EDG__ // TRANSITION, VSO-1900293
@@ -997,4 +1011,7 @@ int main() {
9971011

9981012
STATIC_ASSERT((test_gh_3733(), true));
9991013
test_gh_3733();
1014+
1015+
STATIC_ASSERT((test_gh_4425(), true));
1016+
test_gh_4425();
10001017
}

0 commit comments

Comments
 (0)