Describe the bug
Debug version std::min_element assumes that the range is not modified while working on it.
It triggers the following check:
|
constexpr bool _Debug_lt_pred(_Pr&& _Pred, _Ty1&& _Left, _Ty2&& _Right) noexcept(
|
|
noexcept(_Pred(_Left, _Right)) && noexcept(_Pred(_Right, _Left))) {
|
|
// test if _Pred(_Left, _Right) and _Pred is strict weak ordering, when the arguments are the cv-same-type
|
|
const auto _Result = static_cast<bool>(_Pred(_Left, _Right));
|
|
if (_Result) {
|
|
_STL_VERIFY(!_Pred(_Right, _Left), "invalid comparator");
|
|
}
|
|
|
|
return _Result;
|
|
}
|
This assertion is triggered when std::min_element is used on array of std::atomic values that are incremented independently by concurrent threads.
DevCom-222276 reporter asks:
Are there any limitations in the standard about std::min_elements() that I should know?
Additional context
- Skipped libcxx tests:
|
# Predicate count assertions - IDL2 is slightly bending the Standard's rules here.
|
|
std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp FAIL
|
|
std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp FAIL
|
|
std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp FAIL
|
Also tracked by DevCom-222276 and Microsoft-internal VSO-592348 / AB#592348.
Describe the bug
Debug version
std::min_elementassumes that the range is not modified while working on it.It triggers the following check:
STL/stl/inc/xutility
Lines 1589 to 1598 in 5be7d49
This assertion is triggered when
std::min_elementis used on array ofstd::atomicvalues that are incremented independently by concurrent threads.DevCom-222276 reporter asks:
Additional context
STL/tests/libcxx/expected_results.txt
Lines 586 to 589 in 06827fe
Also tracked by DevCom-222276 and Microsoft-internal VSO-592348 / AB#592348.