diff --git a/stl/inc/algorithm b/stl/inc/algorithm index ce0a039bb16..312e06b0a00 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -638,7 +638,7 @@ _NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( #ifdef __cpp_lib_concepts namespace ranges { - template + template requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> _NODISCARD constexpr bool _Equal_count( _It1 _First1, _It2 _First2, _Size _Count, _Pr _Pred, _Pj1 _Proj1, _Pj2 _Proj2) { @@ -6923,9 +6923,7 @@ namespace ranges { const auto _Count = _RANGES distance(_Range); auto _UResult = _RANGES _Lower_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); - auto _Result = _RANGES begin(_Range); - _Seek_wrapped(_Result, _STD move(_UResult)); - return _Result; + return _Rewrap_iterator(_Range, _STD move(_UResult)); } }; @@ -6978,9 +6976,7 @@ namespace ranges { const auto _Count = _RANGES distance(_Range); auto _UResult = _RANGES _Upper_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); - auto _Result = _RANGES begin(_Range); - _Seek_wrapped(_Result, _STD move(_UResult)); - return _Result; + return _Rewrap_iterator(_Range, _STD move(_UResult)); } }; @@ -9924,13 +9920,10 @@ namespace ranges { indirect_strict_weak_order, _Pj>> _Pr = ranges::less> _NODISCARD constexpr minmax_element_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _First = _RANGES begin(_Range); - auto _UResult = _Minmax_element_fwd_unchecked(_RANGES _Unwrap_range_iter<_Rng>(_STD move(_First)), - _RANGES _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); - _STD _Seek_wrapped(_First, _STD move(_UResult.min)); - auto _Second = _First; - _STD _Seek_wrapped(_Second, _STD move(_UResult.max)); - return {_STD move(_First), _STD move(_Second)}; + auto _UResult = _Minmax_element_fwd_unchecked( + _RANGES _Ubegin(_Range), _RANGES _Uend(_Range), _STD _Pass_fn(_Pred), _STD _Pass_fn(_Proj)); + return { + _Rewrap_iterator(_Range, _STD move(_UResult.min)), _Rewrap_iterator(_Range, _STD move(_UResult.max))}; } private: @@ -10519,11 +10512,9 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _First = _RANGES begin(_Range); - auto _UFirst = _RANGES _Is_sorted_until_unchecked( - _Unwrap_range_iter<_Rng>(_First), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); - _Seek_wrapped(_First, _STD move(_UFirst)); - return _First; + auto _UResult = + _RANGES _Is_sorted_until_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + return _Rewrap_iterator(_Range, _STD move(_UResult)); } }; diff --git a/stl/inc/ranges b/stl/inc/ranges index 58351898000..cf7d9e016bd 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -6682,7 +6682,6 @@ namespace ranges { } #endif // _ITERATOR_DEBUG_LEVEL != 0 - // Per to-be-filed LWG issue (See GH-2995) if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) { _Missing = _RANGES advance(_Current, _Count * _Off, _End); } else { @@ -7642,7 +7641,6 @@ namespace ranges { } #endif // _ITERATOR_DEBUG_LEVEL != 0 - // Per to-be-filed LWG issue (See GH-2995) if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) { _Missing = _RANGES advance(_Current, _Stride * _Off, _End); } else { diff --git a/stl/inc/regex b/stl/inc/regex index aa1974d47e1..05cb7465d3b 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -58,7 +58,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN -enum _Meta_type { // meta character representations for parser +enum _Meta_type : int { // meta character representations for parser _Meta_lpar = '(', _Meta_rpar = ')', _Meta_dlr = '$', diff --git a/stl/inc/sstream b/stl/inc/sstream index 365753b94e0..12a90ae5651 100644 --- a/stl/inc/sstream +++ b/stl/inc/sstream @@ -67,12 +67,12 @@ public: const basic_string<_Elem, _Traits, _Alloc2>& _Str, ios_base::openmode _Mode = ios_base::in | ios_base::out) : basic_stringbuf(_Str, _Mode, _Alloc{}) {} - basic_stringbuf(basic_stringbuf&& _Right, const _Alloc& _Al_) : _Al(_Al_) { + basic_stringbuf(basic_stringbuf&& _Right, const _Alloc& _Al_) : _Mystate(0), _Al(_Al_) { _Assign_rv(_STD move(_Right)); } #endif // _HAS_CXX20 - basic_stringbuf(basic_stringbuf&& _Right) { + basic_stringbuf(basic_stringbuf&& _Right) : _Mystate(0) { _Assign_rv(_STD move(_Right)); } @@ -269,7 +269,7 @@ protected: _Mysb::setp(_Newptr, _New_pnext, _Newptr + _Newsize); if (_Mystate & _Noread) { // maintain eback() == allocated pointer invariant - _Mysb::setg(_Newptr, nullptr, _Newptr); + _Mysb::setg(_Newptr, _Newptr, _Newptr); } else { // if readable, set the get area to initialized region _Mysb::setg(_Newptr, _Newptr + (_Mysb::gptr() - _Oldptr), _Seekhigh); } @@ -328,6 +328,12 @@ protected: pos_type seekoff( off_type _Off, ios_base::seekdir _Way, ios_base::openmode _Mode = ios_base::in | ios_base::out) override { + const bool _Need_read_but_cannot = (_Mode & ios_base::in) != 0 && (_Mystate & _Noread) != 0; + const bool _Need_write_but_cannot = (_Mode & ios_base::out) != 0 && (_Mystate & _Constant) != 0; + if (_Need_read_but_cannot || _Need_write_but_cannot) { + return pos_type{off_type{-1}}; + } + // change position by _Off, according to _Way, _Mode const auto _Gptr_old = _Mysb::gptr(); const auto _Pptr_old = (_Mystate & _Constant) ? nullptr : _Mysb::pptr(); @@ -388,6 +394,12 @@ protected: } pos_type seekpos(pos_type _Pos, ios_base::openmode _Mode = ios_base::in | ios_base::out) override { + const bool _Need_read_but_cannot = (_Mode & ios_base::in) != 0 && (_Mystate & _Noread) != 0; + const bool _Need_write_but_cannot = (_Mode & ios_base::out) != 0 && (_Mystate & _Constant) != 0; + if (_Need_read_but_cannot || _Need_write_but_cannot) { + return pos_type{off_type{-1}}; + } + // change position to _Pos, according to _Mode const auto _Off = static_cast(_Pos); const auto _Gptr_old = _Mysb::gptr(); @@ -440,7 +452,7 @@ protected: _Mysb::setp(_Pnew, (_State & (_Atend | _Append)) ? _Seekhigh : _Pnew, _Seekhigh); if (_State & _Noread) { // maintain "_Allocated == eback() points to buffer base" invariant - _Mysb::setg(_Pnew, nullptr, _Pnew); + _Mysb::setg(_Pnew, _Pnew, _Pnew); } } @@ -469,7 +481,7 @@ protected: _Mysb::setp(_Pnew, _Next, _End_buffer); if (_State & _Noread) { // maintain "_Allocated == eback() points to buffer base" invariant - _Mysb::setg(_Pnew, nullptr, _Pnew); + _Mysb::setg(_Pnew, _Pnew, _Pnew); } else { _Mysb::setg(_Pnew, _Pnew, _Seekhigh); } diff --git a/stl/inc/xutility b/stl/inc/xutility index d4b5112f2de..4353b17e043 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -6683,10 +6683,9 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _First = _RANGES begin(_Range); - _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Unwrap_range_iter<_Rng>(_STD move(_First)), - _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); - return _First; + auto _UResult = + _RANGES _Max_element_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + return _Rewrap_iterator(_Range, _STD move(_UResult)); } }; @@ -6878,10 +6877,9 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { - auto _First = _RANGES begin(_Range); - _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Unwrap_range_iter<_Rng>(_STD move(_First)), - _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); - return _First; + auto _UResult = + _RANGES _Min_element_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); + return _Rewrap_iterator(_Range, _STD move(_UResult)); } }; diff --git a/tests/std/tests/P0896R4_istream_view/test.cpp b/tests/std/tests/P0896R4_istream_view/test.cpp index db9a35a1d01..d007d86c838 100644 --- a/tests/std/tests/P0896R4_istream_view/test.cpp +++ b/tests/std/tests/P0896R4_istream_view/test.cpp @@ -119,6 +119,23 @@ void test_one_type() { static_assert(noexcept(views::istream(wintstream))); assert(ranges::equal(input, expected_vals)); } +#if _HAS_CXX23 + { // Using ranges::istream_view with const iterators + istringstream intstream{"0 1 2 3"}; + T input[] = {-1, -1, -1, -1, -1}; + ranges::istream_view v(intstream); + ranges::copy(v.cbegin(), v.cend(), input); + assert(ranges::equal(input, expected_vals)); + } + + { // Using ranges::wistream_view with const iterators + wistringstream wintstream{L"0 1 2 3"}; + T input[] = {-1, -1, -1, -1, -1}; + ranges::wistream_view v(wintstream); + ranges::copy(v.cbegin(), v.cend(), input); + assert(ranges::equal(input, expected_vals)); + } +#endif // _HAS_CXX23 } istringstream some_stream{"42"}; diff --git a/tests/std/tests/P0896R4_ranges_alg_equal/test.cpp b/tests/std/tests/P0896R4_ranges_alg_equal/test.cpp index 7a85024c423..3b3487887e6 100644 --- a/tests/std/tests/P0896R4_ranges_alg_equal/test.cpp +++ b/tests/std/tests/P0896R4_ranges_alg_equal/test.cpp @@ -79,6 +79,13 @@ constexpr void smoke_test() { assert(!equal(begin(arr1), unreachable_sentinel, begin(arr2), end(arr2))); assert(!equal(begin(arr1), end(arr1), begin(arr2), unreachable_sentinel)); } +#ifndef _M_CEE // TRANSITION, VSO-1666180 + { + // Validate GH-3550: ": ranges::equal does not work for ranges with integer-class range_difference_t" + auto v = ranges::subrange{std::views::iota(0ull, 10ull)} | std::views::drop(2); + assert(equal(v, v)); + } +#endif // _M_CEE } int main() { diff --git a/tests/std/tests/P0896R4_views_empty/test.cpp b/tests/std/tests/P0896R4_views_empty/test.cpp index 5f6a2338b79..252fb5141ec 100644 --- a/tests/std/tests/P0896R4_views_empty/test.cpp +++ b/tests/std/tests/P0896R4_views_empty/test.cpp @@ -20,7 +20,7 @@ constexpr bool test_one_type() { static_assert(ranges::view && ranges::contiguous_range && ranges::sized_range && ranges::common_range); static_assert(ranges::borrowed_range); static_assert(same_as)>); - auto& r = views::empty; + constexpr auto& r = views::empty; // validate member size static_assert(same_as); @@ -50,7 +50,16 @@ constexpr bool test_one_type() { static_assert(noexcept(R::empty())); static_assert(noexcept(ranges::empty(r))); - // validate members inherited from view_interface +#if _HAS_CXX23 + // validate members cbegin and cend inherited from view_interface + static_assert(same_as>); + static_assert(r.cbegin() == nullptr); + + static_assert(same_as>); + static_assert(r.cend() == nullptr); +#endif // _HAS_CXX23 + + // validate other members inherited from view_interface assert(!r); return true; diff --git a/tests/std/tests/P0896R4_views_iota/test.cpp b/tests/std/tests/P0896R4_views_iota/test.cpp index a0fee3aff06..a4e530846fc 100644 --- a/tests/std/tests/P0896R4_views_iota/test.cpp +++ b/tests/std/tests/P0896R4_views_iota/test.cpp @@ -197,6 +197,14 @@ constexpr void test_integral() { static_assert(noexcept(first != last)); // strengthened assert(last - first == 8); static_assert(noexcept(last - first)); // strengthened + +#if _HAS_CXX23 + const same_as> auto cfirst = rng.cbegin(); + assert(cfirst == first); + const same_as> auto clast = rng.cend(); + assert(clast == last); + assert(clast - cfirst == 8); +#endif // _HAS_CXX23 } { @@ -234,6 +242,21 @@ constexpr void test_integral() { } static_assert(!CanSize>); + +#if _HAS_CXX23 + { + const same_as auto rng = views::iota(low); + const ranges::subrange crng{rng.cbegin(), rng.cend()}; + + auto i = low; + for (const auto& e : crng) { + assert(e == i); + if (++i == high) { + break; + } + } + } +#endif // _HAS_CXX23 } } diff --git a/tests/std/tests/P0896R4_views_single/test.cpp b/tests/std/tests/P0896R4_views_single/test.cpp index 18149b0566d..54fc7abfb7c 100644 --- a/tests/std/tests/P0896R4_views_single/test.cpp +++ b/tests/std/tests/P0896R4_views_single/test.cpp @@ -94,6 +94,23 @@ constexpr bool test_one_type(T value, Args&&... args) { static_assert(noexcept(cr0.end())); static_assert(noexcept(ranges::end(cr0))); +#if _HAS_CXX23 + // validate members cbegin and cend + static_assert(same_as); + assert(*r0.cbegin() == value); + assert(r0.cbegin() == ptr); + + static_assert(same_as); + assert(r0.cend() == ptr + 1); + + static_assert(same_as); + assert(*cr0.cbegin() == value); + assert(cr0.cbegin() == cptr); + + static_assert(same_as); + assert(cr0.cend() == cptr + 1); +#endif // _HAS_CXX23 + // validate CTAD and T&& constructor const same_as auto cr1 = ranges::single_view{move(value)}; assert(cr1.data() != nullptr); diff --git a/tests/std/tests/P2474R2_views_repeat/test.cpp b/tests/std/tests/P2474R2_views_repeat/test.cpp index 4c360593b13..ba1f542495f 100644 --- a/tests/std/tests/P2474R2_views_repeat/test.cpp +++ b/tests/std/tests/P2474R2_views_repeat/test.cpp @@ -252,6 +252,16 @@ constexpr void test_common(T val, B bound = unreachable_sentinel) { assert(cmp_equal(last - first, rng.size())); static_assert(noexcept(last - first)); // strengthened } + + const same_as> auto cfirst = rng.cbegin(); + assert(cfirst == first); + const same_as> auto clast = rng.cend(); + if constexpr (ranges::common_range) { + assert(clast == last); + assert(cmp_equal(clast - cfirst, rng.size())); + } else { + static_assert(same_as, unreachable_sentinel_t>); + } } struct move_tester { diff --git a/tests/std/tests/char8_t_17_matrix.lst b/tests/std/tests/char8_t_17_matrix.lst index 97170842230..cfabb7ae85e 100644 --- a/tests/std/tests/char8_t_17_matrix.lst +++ b/tests/std/tests/char8_t_17_matrix.lst @@ -35,3 +35,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/char8_t_impure_matrix.lst b/tests/std/tests/char8_t_impure_matrix.lst index d5a87b4e2c3..f7c9462651c 100644 --- a/tests/std/tests/char8_t_impure_matrix.lst +++ b/tests/std/tests/char8_t_impure_matrix.lst @@ -37,3 +37,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/char8_t_matrix.lst b/tests/std/tests/char8_t_matrix.lst index 12d002c7609..7795932f132 100644 --- a/tests/std/tests/char8_t_matrix.lst +++ b/tests/std/tests/char8_t_matrix.lst @@ -36,3 +36,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/concepts_20_matrix.lst b/tests/std/tests/concepts_20_matrix.lst index 7ce5f2b0e0c..ea8806b97bb 100644 --- a/tests/std/tests/concepts_20_matrix.lst +++ b/tests/std/tests/concepts_20_matrix.lst @@ -27,3 +27,4 @@ PM_CL="/clr /MDd /std:c++20" # PM_CL="/std:c++latest /permissive- /BE /c /EHsc /MTd" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/concepts_latest_matrix.lst b/tests/std/tests/concepts_latest_matrix.lst index 73625bbbb86..ecf410ca036 100644 --- a/tests/std/tests/concepts_latest_matrix.lst +++ b/tests/std/tests/concepts_latest_matrix.lst @@ -22,3 +22,4 @@ PM_CL="/MTd /D_ITERATOR_DEBUG_LEVEL=2 /permissive- /analyze:only /analyze:autolo # PM_CL="/permissive- /BE /c /MTd" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/impure_matrix.lst b/tests/std/tests/impure_matrix.lst index 53e8bf46f1c..a14eb162d57 100644 --- a/tests/std/tests/impure_matrix.lst +++ b/tests/std/tests/impure_matrix.lst @@ -35,3 +35,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/locale0_implib_cpp_matrix.lst b/tests/std/tests/locale0_implib_cpp_matrix.lst index 32992138ddc..73891267e7c 100644 --- a/tests/std/tests/locale0_implib_cpp_matrix.lst +++ b/tests/std/tests/locale0_implib_cpp_matrix.lst @@ -37,3 +37,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/strict_concepts_20_matrix.lst b/tests/std/tests/strict_concepts_20_matrix.lst index e8dd503d44f..cc86671e318 100644 --- a/tests/std/tests/strict_concepts_20_matrix.lst +++ b/tests/std/tests/strict_concepts_20_matrix.lst @@ -26,3 +26,4 @@ PM_CL="/clr /MDd /std:c++20" # PM_CL="/std:c++latest /BE /c /EHsc /MTd" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/strict_concepts_latest_matrix.lst b/tests/std/tests/strict_concepts_latest_matrix.lst index 3b126ab4c16..2604c0e479c 100644 --- a/tests/std/tests/strict_concepts_latest_matrix.lst +++ b/tests/std/tests/strict_concepts_latest_matrix.lst @@ -24,3 +24,4 @@ PM_CL="/MTd /D_ITERATOR_DEBUG_LEVEL=2 /analyze:only /analyze:autolog-" # PM_CL="/BE /c /MTd" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/usual_17_matrix.lst b/tests/std/tests/usual_17_matrix.lst index 510cc46a999..6b82f8ba838 100644 --- a/tests/std/tests/usual_17_matrix.lst +++ b/tests/std/tests/usual_17_matrix.lst @@ -34,3 +34,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/usual_20_matrix.lst b/tests/std/tests/usual_20_matrix.lst index c8aa8e8da23..119e24c2246 100644 --- a/tests/std/tests/usual_20_matrix.lst +++ b/tests/std/tests/usual_20_matrix.lst @@ -24,3 +24,4 @@ PM_CL="/BE /c /EHsc /MD /std:c++20 /permissive-" PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++20 /permissive- /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /std:c++latest /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/usual_latest_matrix.lst b/tests/std/tests/usual_latest_matrix.lst index 0f50c36029c..68e6e2fbcae 100644 --- a/tests/std/tests/usual_latest_matrix.lst +++ b/tests/std/tests/usual_latest_matrix.lst @@ -22,3 +22,4 @@ PM_CL="/BE /c /MD /permissive-" PM_CL="/BE /c /MTd /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MD" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MTd /fp:strict" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /permissive- /MT /fp:strict -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/std/tests/usual_matrix.lst b/tests/std/tests/usual_matrix.lst index bde343a864b..ecf7265160b 100644 --- a/tests/std/tests/usual_matrix.lst +++ b/tests/std/tests/usual_matrix.lst @@ -36,3 +36,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++20 /permissive- /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MTd /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call /EHsc /MT /std:c++latest /permissive- /fp:strict /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/tr1/env.lst b/tests/tr1/env.lst index a6afa08fef3..a814774a4a5 100644 --- a/tests/tr1/env.lst +++ b/tests/tr1/env.lst @@ -31,3 +31,4 @@ PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsin PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++20 /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/tr1/env_minus_md_idl.lst b/tests/tr1/env_minus_md_idl.lst index d9f860c1dbf..2fc8c1b4a5d 100644 --- a/tests/tr1/env_minus_md_idl.lst +++ b/tests/tr1/env_minus_md_idl.lst @@ -26,3 +26,4 @@ PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive- /w14640 /Zc:threadSafeInit- PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17 /w14640 /Zc:threadSafeInit-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive- /w14640 /Zc:threadSafeInit-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- /w14640 /Zc:threadSafeInit- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/tr1/env_minus_pure.lst b/tests/tr1/env_minus_pure.lst index fee56896524..72ffa04557e 100644 --- a/tests/tr1/env_minus_pure.lst +++ b/tests/tr1/env_minus_pure.lst @@ -27,3 +27,4 @@ PM_CL="/BE /c /EHsc /MTd /std:c++latest /permissive-" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MD /std:c++14" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MDd /std:c++17" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MTd /std:c++latest /permissive-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-deprecated-declarations -Wno-self-assign /EHsc /MT /std:c++latest /permissive- -fsanitize=undefined -fno-sanitize-recover=undefined" diff --git a/tests/tr1/tests/chrono/test.cpp b/tests/tr1/tests/chrono/test.cpp index d02fa73132b..635a66a4be0 100644 --- a/tests/tr1/tests/chrono/test.cpp +++ b/tests/tr1/tests/chrono/test.cpp @@ -53,9 +53,9 @@ namespace { CHECK_INT(d_i::max(), STD numeric_limits::max()); typedef STD chrono::duration_values d_d; - CHECK_INT(d_d::zero(), 0.0); - CHECK_INT(d_d::min(), STD numeric_limits::lowest()); - CHECK_INT(d_d::max(), STD numeric_limits::max()); + CHECK_DOUBLE(d_d::zero(), 0.0); + CHECK_DOUBLE(d_d::min(), STD numeric_limits::lowest()); + CHECK_DOUBLE(d_d::max(), STD numeric_limits::max()); } template diff --git a/tests/tr1/tests/cstddef/test.cpp b/tests/tr1/tests/cstddef/test.cpp index c8731270d76..e0d4c158f69 100644 --- a/tests/tr1/tests/cstddef/test.cpp +++ b/tests/tr1/tests/cstddef/test.cpp @@ -20,16 +20,14 @@ typedef struct { } Str; void test_cpp() { // test C++ header - ptrdiff_t zero = 0; - static char* pc = (char*) zero; static const STDx size_t offs[] = {offsetof(Str, f1), offsetof(Str, f2), offsetof(Str, f3)}; - STDx ptrdiff_t pdiff = &pc[INT_MAX] - &pc[0]; + STDx ptrdiff_t pdiff = &offs[2] - &offs[0]; wchar_t wc = L'Z'; Str x = {1, {2}, 3}; char* ps = (char*) &x; CHECK_INT(sizeof(STDx size_t), sizeof(sizeof(char))); - CHECK_INT(pdiff, &pc[INT_MAX] - &pc[0]); + CHECK_INT(pdiff, &offs[2] - &offs[0]); CHECK_INT(wc, L'Z'); CHECK(offs[0] < offs[1]); CHECK_INT((long) *(float*) (ps + offs[1]), 2); diff --git a/tests/tr1/tests/streambuf1/test.cpp b/tests/tr1/tests/streambuf1/test.cpp index ea455177770..78dedcea08e 100644 --- a/tests/tr1/tests/streambuf1/test.cpp +++ b/tests/tr1/tests/streambuf1/test.cpp @@ -28,7 +28,7 @@ class Mybuf : public STD streambuf { } void setp(char* p) { // set pptr - Mybase::setp(p, nullptr); + Mybase::setp(p, p); } char* getp() const { // get pptr diff --git a/tests/tr1/tests/streambuf2/test.cpp b/tests/tr1/tests/streambuf2/test.cpp index 12d7202f466..991adeca90f 100644 --- a/tests/tr1/tests/streambuf2/test.cpp +++ b/tests/tr1/tests/streambuf2/test.cpp @@ -29,7 +29,7 @@ class Mybuf : public STD wstreambuf { } void setp(wchar_t* p) { // set pptr - Mybase::setp(p, nullptr); + Mybase::setp(p, p); } wchar_t* getp() const { // get pptr diff --git a/tests/tr1/tests/type_traits5/test.cpp b/tests/tr1/tests/type_traits5/test.cpp index 9cdf0005555..e0ef94e1d3d 100644 --- a/tests/tr1/tests/type_traits5/test.cpp +++ b/tests/tr1/tests/type_traits5/test.cpp @@ -180,7 +180,7 @@ static void t_add_rvalue_reference() { // test add_rvalue_reference for vario CHECK_TYPEX(STD add_rvalue_reference::type, ARR1 &&); } -typedef enum { red, blue, green } color; +enum color : int { red, blue, green }; static void t_make_signed() { // test make_signed for various types CHECK_TYPE(STD make_signed::type, signed char); diff --git a/tests/utils/stl/test/features.py b/tests/utils/stl/test/features.py index abfa20bbc62..5a8adf8e64c 100644 --- a/tests/utils/stl/test/features.py +++ b/tests/utils/stl/test/features.py @@ -49,6 +49,7 @@ def getDefaultFeatures(config, litConfig): DEFAULT_FEATURES.append(Feature(name='x86')) elif litConfig.target_arch.casefold() == 'x64'.casefold(): + DEFAULT_FEATURES.append(Feature(name='ubsan')) DEFAULT_FEATURES.append(Feature(name='edg')) DEFAULT_FEATURES.append(Feature(name='arch_avx2')) DEFAULT_FEATURES.append(Feature(name='x64')) diff --git a/tests/utils/stl/test/tests.py b/tests/utils/stl/test/tests.py index 09fdeb86fc2..5d10ae30386 100644 --- a/tests/utils/stl/test/tests.py +++ b/tests/utils/stl/test/tests.py @@ -249,8 +249,10 @@ def _parseFlags(self, litConfig): self.requires.append('clr_pure') # TRANSITION, GH-798 elif flag[1:] == 'clr': self.requires.append('clr') # TRANSITION, GH-797 + elif flag[1:] == 'fsanitize=undefined': + self.requires.append('ubsan') # available for x64, see features.py elif flag[1:] == 'BE': - self.requires.append('edg') # available for x86, see features.py + self.requires.append('edg') # available for x64, see features.py elif flag[1:] == 'arch:AVX2': self.requires.append('arch_avx2') # available for x86 and x64, see features.py elif flag[1:] == 'arch:IA32':