From c8d1efb6d504f6392acf8f6d01fd703f7c8826c0 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 31 May 2023 16:38:11 -0700 Subject: [PATCH] Silence 3 static analysis warnings (#3743) Co-authored-by: Casey Carter --- stl/inc/charconv | 3 +++ stl/inc/memory_resource | 3 +++ stl/inc/xlocale | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/stl/inc/charconv b/stl/inc/charconv index 2614acb2ee..428567c131 100644 --- a/stl/inc/charconv +++ b/stl/inc/charconv @@ -253,7 +253,10 @@ _NODISCARD _CONSTEXPR23 from_chars_result _Integer_from_chars( constexpr _Unsigned _Uint_max = static_cast<_Unsigned>(-1); constexpr _Unsigned _Int_max = static_cast<_Unsigned>(_Uint_max >> 1); +#pragma warning(push) +#pragma warning(disable : 26450) // TRANSITION, VSO-1828677 constexpr _Unsigned _Abs_int_min = static_cast<_Unsigned>(_Int_max + 1); +#pragma warning(pop) _Unsigned _Risky_val; _Unsigned _Max_digit; diff --git a/stl/inc/memory_resource b/stl/inc/memory_resource index 9d996bdb85..eee7f03236 100644 --- a/stl/inc/memory_resource +++ b/stl/inc/memory_resource @@ -704,7 +704,10 @@ namespace pmr { static constexpr size_t _Scale(const size_t _Size) noexcept { // scale _Size by 1.5, rounding up to a multiple of alignof(_Header), saturating to _Max_allocation // (keep synchronized with monotonic_buffer_resource::release) +#pragma warning(push) +#pragma warning(disable : 26450) // TRANSITION, VSO-1828677 constexpr auto _Max_size = (_Max_allocation - alignof(_Header) + 1) / 3 * 2; +#pragma warning(pop) if (_Size >= _Max_size) { return _Max_allocation; } diff --git a/stl/inc/xlocale b/stl/inc/xlocale index 9a1c54b228..5a70bb2cb4 100644 --- a/stl/inc/xlocale +++ b/stl/inc/xlocale @@ -257,7 +257,18 @@ public: } } +#pragma warning(push) +#pragma warning(disable : 26495) // Variable 'std::locale::_Ptr' is uninitialized. + // Always initialize a member variable (type.6). + + // We must not explicitly initialize _Ptr here; we rely on it maintaining the value + // previously created in its storage. To be precise: + // In locale0.cpp, locale::_Init() uses True Placement New at classic_locale's address, + // and classic_locale is constructed from the _Noinit enumerator of type _Uninitialized. + // The sequencing is highly unusual; the True Placement New happens before the _Uninitialized construction, + // so while _Ptr here formally has indeterminate value, we expect it to actually keep the previous value. locale(_Uninitialized) {} // defer construction +#pragma warning(pop) locale(const locale& _Right) noexcept : _Ptr(_Right._Ptr) { _Ptr->_Incref();