-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix static analysis warnings #3734
Merged
StephanTLavavej
merged 9 commits into
microsoft:main
from
StephanTLavavej:static-analysis-2
May 31, 2023
Merged
Fix static analysis warnings #3734
StephanTLavavej
merged 9 commits into
microsoft:main
from
StephanTLavavej:static-analysis-2
May 31, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…zed. Always initialize a member variable (type.6)."
…r `_Big_integer_flt::_Mydata`.
…race': return/function has 'SAL_success(return!=0)' on the prior instance. See [...]\winnt.h(20721)."
…t 'noexcept' (f.6)." Add `noexcept(false)` because these move ctors call `basic_ios::init()` => `ios_base::_Init()` => `new locale`. `list` dynamically allocates a sentinel node.
…w at compile time. Use a wider type to store the operands (io.1)." and warning C26454 "Arithmetic overflow: '-' operation produces a negative unsigned result at compile time (io.5)." We can avoid these warnings by directly forming the values, which is also easier to read. C:\Temp>type meow.cpp #include <climits> #include <iostream> using namespace std; static_assert((1ul << 31) == 0 - static_cast<unsigned long>(LONG_MIN)); static_assert((1ull << 63) == 0 - static_cast<unsigned long long>(LLONG_MIN)); int main() { cout << 0 - static_cast<unsigned long>(LONG_MIN) << endl; cout << (1ul << 31) << endl; cout << 0 - static_cast<unsigned long long>(LLONG_MIN) << endl; cout << (1ull << 63) << endl; } C:\Temp>cl /EHsc /nologo /W4 meow.cpp && meow meow.cpp 2147483648 2147483648 9223372036854775808 9223372036854775808
…ling function 'ReleaseSRWLockExclusive'." We're implementing lock machinery, so we have to assume that the lock is held here.
I'm speculatively mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Added one more change before mirroring. |
CaseyCarter
requested changes
May 27, 2023
CaseyCarter
approved these changes
May 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The MSVC-internal repo is making another push to enable and clean up static analysis warnings in the build. The STL was previously unaffected as we've built our tests with plain
/analyze
for 3000 years, but now additional rulesets are being enabled and the STL is emitting warnings._Big_integer_flt::_Mydata
.'RtlCaptureStackBackTrace'
: return/function has'SAL_success(return!=0)'
on the prior instance. See[...]\winnt.h(20721)
."'noexcept'
(f.6)."noexcept(false)
because these move ctors callbasic_ios::init()
=>ios_base::_Init()
=>new locale
.list
dynamically allocates a sentinel node.'-'
operation causes overflow at compile time. Use a wider type to store the operands (io.1)." and warning C26454 "Arithmetic overflow:'-'
operation produces a negative unsigned result at compile time (io.5)."'ReleaseSRWLockExclusive'
."<charconv>
, work around VSO-1826196 "False positive C26454 in charconv". This has already been fixed in the latest compiler sources, we just need to wait for the MSVC-internal toolset to be updated. Thanks to @dmitrykobets-msft for investigating this.