Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence 3 static analysis warnings #3743

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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