Fix MSVC warning C26495: ZwQuerySystemInformation, m_MetaDataObjectValue uninitialized#3843
Merged
dzenanz merged 2 commits intoInsightSoftwareConsortium:masterfrom Jan 4, 2023
Conversation
Fixed VS2019 Code Analysis warnings, saying: > warning C26495: Variable 'itk::MetaDataObject::m_MetaDataObjectValue' is uninitialized. > Always initialize a member variable (type.6) Note that `MetaDataObject<MetaDataObjectType>` is a rather "expensive" class (typically heap-allocated, and having a virtual table), so the extra cost of the added initialization appears relatively low.
Fixed VS2019 Code Analysis warnings, saying: > warning C26495: Variable 'itk::WindowsMemoryUsageObserver::ZwQuerySystemInformation' is uninitialized. > Always initialize a member variable (type.6). Also added an in-class default member initializer to m_hNTLib, which was not yet initialized by the default-constructor of WindowsMemoryUsageObserver either. Note that `WindowsMemoryUsageObserver` is a rather "expensive" class (having a virtual table) and its default-constructor is already non-trivial, so the extra cost of the added initialization appears relatively low.
dzenanz
approved these changes
Jan 2, 2023
Contributor
Author
|
Note that MSVC/Code Analysis does not always produce this warning about uninitialized member variables, when it should. As I reported at developercommunity.visualstudio.com: False negative (missing) /analyze warning C26495: Variable is uninitialized. Always initialize a member variable (type.6). For a code example, see https://godbolt.org/z/c4GhdPMc8 So even when all of those "C26495" warnings would be fixed, there might still be some more uninitialized member variables... So please upvote my MSVC bug report: https://developercommunity.visualstudio.com/t/False-negative-missing-analyze-warnin/10239447 |
This file contains hidden or 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
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.
Fixed Visual Studio 2019 Code Analysis warnings from both
MetaDataObjectandWindowsMemoryUsageObserver, saying: