diff --git a/README.md b/README.md index 2ed5d8af157..02ade81ea2d 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem # How To Build With The Visual Studio IDE -1. Install Visual Studio 2022 17.13 Preview 3 or later. +1. Install Visual Studio 2022 17.13 Preview 4 or later. * Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer. * Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer if you would like to build the ARM64/ARM64EC target. @@ -160,7 +160,7 @@ Just try to follow these rules, so we can spend more time fixing bugs and implem # How To Build With A Native Tools Command Prompt -1. Install Visual Studio 2022 17.13 Preview 3 or later. +1. Install Visual Studio 2022 17.13 Preview 4 or later. * Select "Windows 11 SDK (10.0.22621.0)" in the VS Installer. * Select "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)" in the VS Installer if you would like to build the ARM64/ARM64EC target. diff --git a/azure-devops/config.yml b/azure-devops/config.yml index 111b6eab4f3..fc8be111087 100644 --- a/azure-devops/config.yml +++ b/azure-devops/config.yml @@ -5,7 +5,7 @@ variables: - name: poolName - value: 'StlBuild-2025-01-22T1525-Pool' + value: 'StlBuild-2025-01-28T1106-Pool' readonly: true - name: poolDemands value: 'EnableSpotVM -equals false' diff --git a/azure-devops/provision-image.ps1 b/azure-devops/provision-image.ps1 index 630b6676dd4..6a29f6e03f1 100644 --- a/azure-devops/provision-image.ps1 +++ b/azure-devops/provision-image.ps1 @@ -40,7 +40,7 @@ foreach ($workload in $VisualStudioWorkloads) { } # https://github.com/PowerShell/PowerShell/releases/latest -$PowerShellUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/PowerShell-7.4.6-win-x64.msi' +$PowerShellUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.5.0/PowerShell-7.5.0-win-x64.msi' $PowerShellArgs = @('/quiet', '/norestart') $PythonUrl = 'https://www.python.org/ftp/python/3.13.1/python-3.13.1-amd64.exe' diff --git a/stl/inc/__msvc_chrono.hpp b/stl/inc/__msvc_chrono.hpp index 7f5adad907e..8a89e462473 100644 --- a/stl/inc/__msvc_chrono.hpp +++ b/stl/inc/__msvc_chrono.hpp @@ -653,16 +653,6 @@ namespace chrono { using time_point = _CHRONO time_point; static constexpr bool is_steady = true; -#if defined(_M_ARM) || defined(_M_ARM64) // vvv ARM or ARM64 arch vvv -#define _LIKELY_ARM_ARM64 _LIKELY -#define _LIKELY_X86_X64 -#elif defined(_M_IX86) || defined(_M_X64) // ^^^ ARM or ARM64 arch / x86 or x64 arch vvv -#define _LIKELY_ARM_ARM64 -#define _LIKELY_X86_X64 _LIKELY -#else // ^^^ x86 or x64 arch / other arch vvv -#define _LIKELY_ARM_ARM64 -#define _LIKELY_X86_X64 -#endif // ^^^ other arch ^^^ _NODISCARD static time_point now() noexcept { // get current time const long long _Freq = _Query_perf_frequency(); // doesn't change after system boot const long long _Ctr = _Query_perf_counter(); @@ -671,15 +661,14 @@ namespace chrono { // multiplies instead of divides to calculate the nanosecond value. constexpr long long _TenMHz = 10'000'000; constexpr long long _TwentyFourMHz = 24'000'000; - // clang-format off - if (_Freq == _TenMHz) _LIKELY_X86_X64 { + if (_Freq == _TenMHz) { // 10 MHz is a very common QPC frequency on modern x86/x64 PCs. Optimizing for // this specific frequency can double the performance of this function by // avoiding the expensive frequency conversion path. static_assert(period::den % _TenMHz == 0, "It should never fail."); constexpr long long _Multiplier = period::den / _TenMHz; return time_point(duration(_Ctr * _Multiplier)); - } else if (_Freq == _TwentyFourMHz) _LIKELY_ARM_ARM64 { + } else if (_Freq == _TwentyFourMHz) { // 24 MHz is a common frequency on ARM/ARM64, including cases where it emulates x86/x64. const long long _Whole = (_Ctr / _TwentyFourMHz) * period::den; const long long _Part = (_Ctr % _TwentyFourMHz) * period::den / _TwentyFourMHz; @@ -694,10 +683,7 @@ namespace chrono { const long long _Part = (_Ctr % _Freq) * period::den / _Freq; return time_point(duration(_Whole + _Part)); } - // clang-format on } -#undef _LIKELY_ARM_ARM64 -#undef _LIKELY_X86_X64 }; } // namespace chrono _STD_END diff --git a/stl/inc/__msvc_ranges_tuple_formatter.hpp b/stl/inc/__msvc_ranges_tuple_formatter.hpp index 8f544704594..9b4595db7a3 100644 --- a/stl/inc/__msvc_ranges_tuple_formatter.hpp +++ b/stl/inc/__msvc_ranges_tuple_formatter.hpp @@ -1081,7 +1081,7 @@ struct _Range_default_formatter<_Kind, _Rng, _CharT> { if constexpr (_RANGES contiguous_range<_Range_type>) { const auto _Size = _STD _To_unsigned_like(_RANGES distance(_Rx)); - if (!_STD in_range(_Size)) [[unlikely]] { + if (!_STD in_range(_Size)) { _Throw_format_error("Formatted range is too long."); } diff --git a/stl/inc/ostream b/stl/inc/ostream index 3357fd3aad1..bf8fb820728 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -87,7 +87,7 @@ ios_base::iostate _Print_noformat_nonunicode(ostream& _Ostr, const string_view _ _TRY_IO_BEGIN const auto _Characters_written = _Ostr.rdbuf()->sputn(_Str.data(), static_cast(_Str.size())); const bool _Was_insertion_successful = static_cast(_Characters_written) == _Str.size(); - if (!_Was_insertion_successful) [[unlikely]] { + if (!_Was_insertion_successful) { _State |= ios_base::badbit; } _CATCH_IO_(ios_base, _Ostr) @@ -105,7 +105,7 @@ ios_base::iostate _Print_newline_only_nonunicode(ostream& _Ostr) { _TRY_IO_BEGIN const bool _Was_insertion_successful = _Ostr.rdbuf()->sputc('\n') == '\n'; - if (!_Was_insertion_successful) [[unlikely]] { + if (!_Was_insertion_successful) { _State |= ios_base::badbit; } _CATCH_IO_(ios_base, _Ostr) @@ -119,9 +119,9 @@ void _Vprint_nonunicode_impl( const ostream::sentry _Ok(_Ostr); ios_base::iostate _State = ios_base::goodbit; - if (!_Ok) [[unlikely]] { + if (!_Ok) { _State |= ios_base::badbit; - } else [[likely]] { + } else { // This is intentionally kept outside of the try/catch block in _Print_noformat_nonunicode() // (see N4950 [ostream.formatted.print]/3.2). string _Output_str = _STD vformat(_Ostr.getloc(), _Fmt_str, _Fmt_args); @@ -178,24 +178,24 @@ ios_base::iostate _Do_on_maybe_unicode_console( break; case __std_win_error::_Not_supported: - [[unlikely]] return _State; + return _State; default: - [[unlikely]] return ios_base::failbit; + return ios_base::failbit; } #pragma warning(pop) if (_Is_unicode_console) { _TRY_IO_BEGIN const bool _Was_flush_successful = _Ostr.rdbuf()->pubsync() != -1; - if (!_Was_flush_successful) [[unlikely]] { + if (!_Was_flush_successful) { _State |= ios_base::badbit; return _State; } const __std_win_error _Unicode_console_print_result = _Unicode_console_func(_Unicode_console_retrieval_result._Console_handle); - if (_Unicode_console_print_result != __std_win_error::_Success) [[unlikely]] { + if (_Unicode_console_print_result != __std_win_error::_Success) { _State |= ios_base::badbit; } _CATCH_IO_(ios_base, _Ostr) @@ -234,9 +234,9 @@ void _Vprint_unicode_impl( const ostream::sentry _Ok(_Ostr); ios_base::iostate _State = ios_base::goodbit; - if (!_Ok) [[unlikely]] { + if (!_Ok) { _State |= ios_base::badbit; - } else [[likely]] { + } else { // This is intentionally kept outside of the try/catch block in _Print_noformat_unicode() // (see N4950 [ostream.formatted.print]/3.2). string _Output_str = _STD vformat(_Ostr.getloc(), _Fmt_str, _Fmt_args); @@ -255,9 +255,9 @@ void _Print_noformat(ostream& _Ostr, const string_view _Str) { const ostream::sentry _Ok(_Ostr); ios_base::iostate _State = ios_base::goodbit; - if (!_Ok) [[unlikely]] { + if (!_Ok) { _State |= ios_base::badbit; - } else [[likely]] { + } else { if constexpr (_STD _Is_ordinary_literal_encoding_utf8()) { _State |= _STD _Print_noformat_unicode(_Ostr, _Str); } else { @@ -302,9 +302,9 @@ void println(ostream& _Ostr) { const ostream::sentry _Ok(_Ostr); ios_base::iostate _State = ios_base::goodbit; - if (!_Ok) [[unlikely]] { + if (!_Ok) { _State |= ios_base::badbit; - } else [[likely]] { + } else { if constexpr (_STD _Is_ordinary_literal_encoding_utf8()) { _State |= _STD _Print_newline_only_unicode(_Ostr); } else { diff --git a/stl/inc/print b/stl/inc/print index ccb812ddd52..c34d2e89fcc 100644 --- a/stl/inc/print +++ b/stl/inc/print @@ -61,7 +61,7 @@ private: inline void _Print_noformat_nonunicode_nonlocking(FILE* const _Stream, const string_view _Str) { const bool _Was_write_successful = _CSTD _fwrite_nolock(_Str.data(), 1, _Str.size(), _Stream) == _Str.size(); - if (!_Was_write_successful) [[unlikely]] { + if (!_Was_write_successful) { _Throw_system_error(static_cast(errno)); } } @@ -99,7 +99,7 @@ inline void _Print_noformat_unicode_to_console_nonlocking( const __std_unicode_console_handle _Console_handle, const string_view _Str) { const __std_win_error _Console_print_result = __std_print_to_unicode_console(_Console_handle, _Str.data(), _Str.size()); - if (_Console_print_result != __std_win_error::_Success) [[unlikely]] { + if (_Console_print_result != __std_win_error::_Success) { _STD _Throw_system_error_from_std_win_error(_Console_print_result); } } @@ -160,10 +160,10 @@ void _Do_on_maybe_unicode_console( break; case __std_win_error::_Not_supported: - [[unlikely]] return; + return; default: - [[unlikely]] _STD _Throw_system_error_from_std_win_error(_Unicode_console_retrieval_result._Error); + _STD _Throw_system_error_from_std_win_error(_Unicode_console_retrieval_result._Error); } #pragma warning(pop) @@ -180,7 +180,7 @@ inline void _Vprint_unicode_noformat_impl(FILE* const _Stream, const string_view const _Stream_lock_guard _Guard{_Stream}; const bool _Was_flush_successful = _CSTD _fflush_nolock(_Stream) == 0; - if (!_Was_flush_successful) [[unlikely]] { + if (!_Was_flush_successful) { _Throw_system_error(static_cast(errno)); } @@ -195,7 +195,7 @@ inline void _Vprint_unicode_noformat_impl(FILE* const _Stream, const string_view inline void _Fputc_newline(FILE* const _Stream) { const bool _Was_write_successful = _CSTD fputc('\n', _Stream) == '\n'; - if (!_Was_write_successful) [[unlikely]] { + if (!_Was_write_successful) { _Throw_system_error(static_cast(errno)); } } @@ -203,12 +203,12 @@ inline void _Fputc_newline(FILE* const _Stream) { inline void _Print_newline_only_unicode(FILE* const _Stream) { const auto _Unicode_console = [&](const __std_unicode_console_handle _Console_handle) { const bool _Was_flush_successful = _CSTD fflush(_Stream) == 0; - if (!_Was_flush_successful) [[unlikely]] { + if (!_Was_flush_successful) { _Throw_system_error(static_cast(errno)); } const __std_win_error _Console_print_result = __std_print_newline_only_to_unicode_console(_Console_handle); - if (_Console_print_result != __std_win_error::_Success) [[unlikely]] { + if (_Console_print_result != __std_win_error::_Success) { _STD _Throw_system_error_from_std_win_error(_Console_print_result); } }; @@ -234,7 +234,7 @@ inline void _Vprint_unicode_impl( const _Stream_lock_guard _Guard{_Stream}; const bool _Was_flush_successful = _CSTD _fflush_nolock(_Stream) == 0; - if (!_Was_flush_successful) [[unlikely]] { + if (!_Was_flush_successful) { _Throw_system_error(static_cast(errno)); } diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 7ba2935d369..2fd2c64578f 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -327,32 +327,6 @@ struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> { _EXPORT_STD template constexpr bool is_convertible_v = __is_convertible_to(_From, _To); -#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-1627396 -template -struct is_convertible<_Ty&, volatile _Ty&> : true_type {}; - -template -struct is_convertible : true_type {}; - -template -struct is_convertible<_Ty&, const volatile _Ty&> : true_type {}; - -template -struct is_convertible : true_type {}; - -template -constexpr bool is_convertible_v<_Ty&, volatile _Ty&> = true; - -template -constexpr bool is_convertible_v = true; - -template -constexpr bool is_convertible_v<_Ty&, const volatile _Ty&> = true; - -template -constexpr bool is_convertible_v = true; -#endif // ^^^ workaround ^^^ - _EXPORT_STD template struct is_enum : bool_constant<__is_enum(_Ty)> {}; // determine whether _Ty is an enumerated type @@ -2205,13 +2179,7 @@ struct _Is_trivially_swappable : bool_constant<_Is_trivially_swappable_v<_Ty>> { #if _HAS_CXX20 _EXPORT_STD template -concept convertible_to = -#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-1627396 - is_convertible_v<_From, _To> -#else // ^^^ workaround / no workaround vvv - __is_convertible_to(_From, _To) -#endif // ^^^ no workaround ^^^ - && requires { static_cast<_To>(_STD declval<_From>()); }; +concept convertible_to = __is_convertible_to(_From, _To) && requires { static_cast<_To>(_STD declval<_From>()); }; template concept _Ref_wrap_common_reference_exists_with = _Is_specialization_v<_RefWrap, reference_wrapper> && requires { diff --git a/stl/inc/xstring b/stl/inc/xstring index ea4393dae3d..6d5954ea93f 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -2418,6 +2418,10 @@ public: [](_Elem* const _New_ptr, const _Elem* const _Old_ptr, const size_type _Old_size) _STATIC_CALL_OPERATOR { _Traits::copy(_New_ptr, _Old_ptr, _Old_size + 1); }); + // `_Reallocate_grow_by` calls `_ASAN_STRING_CREATE` assuming that the string + // has size (initialized memory) equal to its new capacity (allocated memory). + // This is not true for the `reserve` method, so we modify the ASan annotation. + _ASAN_STRING_MODIFY(*this, _Mypair._Myval2._Mysize, _Old_size); _Mypair._Myval2._Mysize = _Old_size; } @@ -2442,6 +2446,10 @@ public: [](_Elem* const _New_ptr, const _Elem* const _Old_ptr, const size_type _Old_size) _STATIC_CALL_OPERATOR { _Traits::copy(_New_ptr, _Old_ptr, _Old_size + 1); }); + // `_Reallocate_grow_by` calls `_ASAN_STRING_CREATE` assuming that the string + // has size (initialized memory) equal to its new capacity (allocated memory). + // This is not true for the `reserve` method, so we modify the ASan annotation. + _ASAN_STRING_MODIFY(*this, _Mypair._Myval2._Mysize, _Old_size); _Mypair._Myval2._Mysize = _Old_size; return; } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 95e70c0cd59..5cbd5be87d9 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -566,20 +566,6 @@ #define _FALLTHROUGH #endif -#ifndef __has_cpp_attribute // vvv no attributes vvv -#define _LIKELY -#define _UNLIKELY -#elif __has_cpp_attribute(likely) >= 201803L && __has_cpp_attribute(unlikely) >= 201803L // ^^^ no attr / C++20 attr vvv -#define _LIKELY [[likely]] -#define _UNLIKELY [[unlikely]] -#elif defined(__clang__) // ^^^ C++20 attributes / clang attributes and C++17 or C++14 vvv -#define _LIKELY [[__likely__]] -#define _UNLIKELY [[__unlikely__]] -#else // ^^^ clang attributes and C++17 or C++14 / C1XX attributes and C++17 or C++14 vvv -#define _LIKELY -#define _UNLIKELY -#endif // ^^^ C1XX attributes and C++17 or C++14 ^^^ - // _HAS_NODISCARD (in vcruntime.h) controls: // [[nodiscard]] attributes on STL functions diff --git a/stl/src/print.cpp b/stl/src/print.cpp index 77c31478675..89b4a8964e8 100644 --- a/stl/src/print.cpp +++ b/stl/src/print.cpp @@ -16,24 +16,24 @@ extern "C" { [[nodiscard]] _Success_(return._Error == __std_win_error::_Success) __std_unicode_console_retrieval_result __stdcall __std_get_unicode_console_handle_from_file_stream(_In_ FILE* const _Stream) noexcept { - if (_Stream == nullptr) [[unlikely]] { + if (_Stream == nullptr) { return __std_unicode_console_retrieval_result{._Error = __std_win_error::_Invalid_parameter}; } const int _Fd = _fileno(_Stream); - if (_Fd == -2) [[unlikely]] { + if (_Fd == -2) { // According to https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fileno?view=msvc-170 , // _fileno() returns -2 if _Stream refers to either stdout or stderr and there is no associated output stream. // In that case, there is also no associated console HANDLE. (We haven't observed this happening in practice.) return __std_unicode_console_retrieval_result{._Error = __std_win_error::_Not_supported}; - } else if (_Fd == -1) [[unlikely]] { + } else if (_Fd == -1) { return __std_unicode_console_retrieval_result{._Error = __std_win_error::_Invalid_parameter}; } const HANDLE _Console_handle = reinterpret_cast(_get_osfhandle(_Fd)); - if (_Console_handle == INVALID_HANDLE_VALUE) [[unlikely]] { + if (_Console_handle == INVALID_HANDLE_VALUE) { return __std_unicode_console_retrieval_result{._Error = __std_win_error::_Invalid_parameter}; } @@ -89,7 +89,7 @@ namespace { ::new (&_Str) _Heap_string(_malloc_crt_t(wchar_t, _Capacity)); // Activate _Str - if (!_Str) [[unlikely]] { + if (!_Str) { _Str_capacity = _Buffer_size; _Buffer[0] = L'\0'; // Activate _Buffer return false; @@ -149,7 +149,7 @@ namespace { const char* const _Str, const size_t _Str_size) noexcept { constexpr size_t _Max_str_segment_size = 8192; - if (_Str_size <= _Max_str_segment_size) [[likely]] { + if (_Str_size <= _Max_str_segment_size) { return _Minimal_string_view{_Str, _Str_size}; } @@ -210,7 +210,7 @@ namespace { [[nodiscard]] _Transcode_result _Transcode_utf8_string( _Allocated_string& _Dst_str, const _Minimal_string_view _Src_str) noexcept { // MultiByteToWideChar() fails if strLength == 0. - if (_Src_str._Empty()) [[unlikely]] { + if (_Src_str._Empty()) { return {}; } @@ -220,19 +220,19 @@ namespace { const int32_t _Num_chars_required = MultiByteToWideChar(CP_UTF8, 0, _Src_str._Data(), static_cast(_Src_str._Size()), nullptr, 0); - if (_Num_chars_required == 0) [[unlikely]] { + if (_Num_chars_required == 0) { return static_cast<__std_win_error>(GetLastError()); } const bool _Has_space = _Dst_str._Grow(static_cast(_Num_chars_required)); - if (!_Has_space) [[unlikely]] { + if (!_Has_space) { return __std_win_error::_Not_enough_memory; } const int32_t _Conversion_result = MultiByteToWideChar(CP_UTF8, 0, _Src_str._Data(), static_cast(_Src_str._Size()), _Dst_str._Data(), static_cast(_Dst_str._Capacity())); - if (_Conversion_result == 0) [[unlikely]] { + if (_Conversion_result == 0) { // This shouldn't happen... _CSTD abort(); } @@ -245,7 +245,7 @@ namespace { const BOOL _Write_result = WriteConsoleW(_Console_handle, _Wide_str._Data(), static_cast(_Wide_str._Size()), nullptr, nullptr); - if (!_Write_result) [[unlikely]] { + if (!_Write_result) { return static_cast<__std_win_error>(GetLastError()); } @@ -258,7 +258,7 @@ extern "C" { [[nodiscard]] _Success_(return == __std_win_error::_Success) __std_win_error __stdcall __std_print_to_unicode_console(_In_ const __std_unicode_console_handle _Console_handle, _In_reads_(_Str_size) const char* const _Str, _In_ const size_t _Str_size) noexcept { - if (_Console_handle == __std_unicode_console_handle::_Invalid || _Str == nullptr) [[unlikely]] { + if (_Console_handle == __std_unicode_console_handle::_Invalid || _Str == nullptr) { return __std_win_error::_Invalid_parameter; } @@ -277,13 +277,13 @@ extern "C" { _Curr_str_segment = _Get_next_utf8_string_segment(_Remaining_str, _Remaining_str_size); _Transcoded_str = _Transcode_utf8_string(_Allocated_str, _Curr_str_segment); - if (!_Transcoded_str._Has_value()) [[unlikely]] { + if (!_Transcoded_str._Has_value()) { return _Transcoded_str._Error(); } const __std_win_error _Write_result = _Write_console(_Actual_console_handle, _Transcoded_str._Value()); - if (_Write_result != __std_win_error::_Success) [[unlikely]] { + if (_Write_result != __std_win_error::_Success) { return _Write_result; } @@ -300,7 +300,7 @@ extern "C" { [[nodiscard]] _Success_(return == __std_win_error::_Success) __std_win_error __stdcall __std_print_newline_only_to_unicode_console( _In_ const __std_unicode_console_handle _Console_handle) noexcept { - if (_Console_handle == __std_unicode_console_handle::_Invalid) [[unlikely]] { + if (_Console_handle == __std_unicode_console_handle::_Invalid) { return __std_win_error::_Invalid_parameter; } @@ -308,7 +308,7 @@ extern "C" { const BOOL _Write_result = WriteConsoleW(_Actual_console_handle, L"\n", 1, nullptr, nullptr); - if (!_Write_result) [[unlikely]] { + if (!_Write_result) { return static_cast<__std_win_error>(GetLastError()); } diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index de8eec5a04e..bbdd8ff2094 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -5310,7 +5310,7 @@ namespace { _Size_convert = _Size_bits; for (size_t _Ix = _Size_bits; _Ix < _Size_chars; ++_Ix) { - if (const _Elem _Cur = _Src[_Ix]; _Cur != _Elem0 && _Cur != _Elem1) [[unlikely]] { + if (const _Elem _Cur = _Src[_Ix]; _Cur != _Elem0 && _Cur != _Elem1) { return false; } } @@ -5321,7 +5321,7 @@ namespace { for (size_t _Ix = 0; _Ix != _Size_convert; ++_Ix) { const _Elem _Cur = _Src[_Size_convert - _Ix - 1]; - if (_Cur != _Elem0 && _Cur != _Elem1) [[unlikely]] { + if (_Cur != _Elem0 && _Cur != _Elem1) { return false; } diff --git a/tests/std/tests/GH_002030_asan_annotate_string/test.cpp b/tests/std/tests/GH_002030_asan_annotate_string/test.cpp index 5d869884177..e8bf4d30c3e 100644 --- a/tests/std/tests/GH_002030_asan_annotate_string/test.cpp +++ b/tests/std/tests/GH_002030_asan_annotate_string/test.cpp @@ -20,6 +20,8 @@ #include #include #include + +#include #if _HAS_CXX17 #include #endif // _HAS_CXX17 @@ -1917,17 +1919,32 @@ void test_gh_3955() { assert(s == t); } -int main() { - run_allocator_matrix(); +void test_gh_5251() { + // GH-5251 : ASan annotations do not prevent writing to allocated + // but uninitialized basic_string memory + string myString; + myString.reserve(100); + char* myData = &myString[0]; + myData[50] = 'A'; // ASan should fire! +} + +int main(int argc, char* argv[]) { + std_testing::death_test_executive exec([] { + run_allocator_matrix(); #ifdef __cpp_char8_t - run_allocator_matrix(); + run_allocator_matrix(); #endif // __cpp_char8_t - run_allocator_matrix(); - run_allocator_matrix(); - run_allocator_matrix(); - - test_DevCom_10116361(); - test_DevCom_10109507(); - test_gh_3883(); - test_gh_3955(); + run_allocator_matrix(); + run_allocator_matrix(); + run_allocator_matrix(); + + test_DevCom_10116361(); + test_DevCom_10109507(); + test_gh_3883(); + test_gh_3955(); + }); +#ifdef __SANITIZE_ADDRESS__ + exec.add_death_tests({test_gh_5251}); +#endif // ASan instrumentation enabled + return exec.run(argc, argv); } diff --git a/tests/std/tests/P0898R3_concepts/test.cpp b/tests/std/tests/P0898R3_concepts/test.cpp index 86aa9df97d1..7ec70ccbfa9 100644 --- a/tests/std/tests/P0898R3_concepts/test.cpp +++ b/tests/std/tests/P0898R3_concepts/test.cpp @@ -513,10 +513,8 @@ namespace test_convertible_to { static_assert(convertible_to>); // volatile array glvalues -#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-1627396 static_assert(convertible_to); static_assert(convertible_to); -#endif // ^^^ no workaround ^^^ static_assert(convertible_to); static_assert(convertible_to); @@ -696,10 +694,8 @@ namespace test_common_reference_with { static_assert(test>()); static_assert(test()); -#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-1627396 static_assert(test()); static_assert(test()); -#endif // ^^^ no workaround ^^^ static_assert(test()); static_assert(test()); } // namespace test_common_reference_with @@ -2022,10 +2018,8 @@ namespace test_swappable_with { static_assert(test()); -#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-1627396 static_assert(test()); static_assert(test()); -#endif // ^^^ no workaround ^^^ static_assert(test() == is_permissive); static_assert(test()); diff --git a/tests/std/tests/P1502R1_standard_library_header_units/custom_format.py b/tests/std/tests/P1502R1_standard_library_header_units/custom_format.py index 6d1cfc6fc3a..bcb09e3ec35 100644 --- a/tests/std/tests/P1502R1_standard_library_header_units/custom_format.py +++ b/tests/std/tests/P1502R1_standard_library_header_units/custom_format.py @@ -62,9 +62,7 @@ def getBuildSteps(self, test, litConfig, shared): # Generate JSON files that record how these headers depend on one another. if noisyProgress: print('Scanning dependencies...') - cmd = [test.cxx, *test.flags, *test.compileFlags, *clOptions, '/scanDependencies', '.\\', - '/shallowScan', # TRANSITION, VSO-2293247 fixed in VS 2022 17.13 Preview 4 (remove /shallowScan) - *allHeaders] + cmd = [test.cxx, *test.flags, *test.compileFlags, *clOptions, '/scanDependencies', '.\\', *allHeaders] yield TestStep(cmd, shared.execDir, shared.env, False) # The JSON files also record what object files will be produced. diff --git a/tests/std/tests/P2093R14_formatted_output/test.cpp b/tests/std/tests/P2093R14_formatted_output/test.cpp index d8944462de2..cf7ba595827 100644 --- a/tests/std/tests/P2093R14_formatted_output/test.cpp +++ b/tests/std/tests/P2093R14_formatted_output/test.cpp @@ -42,13 +42,13 @@ namespace test { console_handle = CreateConsoleScreenBuffer(screen_buffer_access, 0, nullptr, CONSOLE_TEXTMODE_BUFFER, nullptr); - if (console_handle == INVALID_HANDLE_VALUE) [[unlikely]] { + if (console_handle == INVALID_HANDLE_VALUE) { return; } const int console_fd = _open_osfhandle(reinterpret_cast(console_handle), _O_TEXT); - if (console_fd == -1) [[unlikely]] { + if (console_fd == -1) { return; } @@ -109,9 +109,9 @@ namespace test { // those space characters which appear after the user's text. const size_t lastValidChar = output_str.find_last_not_of(' '); - if (lastValidChar == wstring::npos) [[unlikely]] { + if (lastValidChar == wstring::npos) { output_str.clear(); - } else [[likely]] { + } else { output_str = output_str.substr(0, lastValidChar + 1); } @@ -120,7 +120,7 @@ namespace test { private: void delete_console() { - if (is_console_valid()) [[likely]] { + if (is_console_valid()) { // According to the MSDN, we don't call CloseHandle() on handles passed to _open_osfhandle(), // and we don't call _close() on file descriptors passed to _fdopen(). So, our only clean-up // task is to call fclose().