Skip to content

Commit

Permalink
Silence 3 static analysis warnings (#3743)
Browse files Browse the repository at this point in the history
Co-authored-by: Casey Carter <[email protected]>
  • Loading branch information
StephanTLavavej and CaseyCarter authored May 31, 2023
1 parent 6a98456 commit c8d1efb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stl/inc/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions stl/inc/xlocale
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c8d1efb

Please sign in to comment.