Fix couple issues with missing operatorEqVarError#4576
Merged
danmar merged 2 commits intocppcheck-opensource:mainfrom Nov 5, 2022
Merged
Conversation
Collaborator
|
This looks reasonable. Let's try it. You can check the diff here in a couple of days: |
| for (const Type::BaseInfo& i : scope->definedType->derivedFrom) { | ||
| const Type *derivedFrom = i.type; | ||
|
|
||
| assignAllVarsVisibleFromScope(usageList, derivedFrom->classScope); |
Collaborator
There was a problem hiding this comment.
Looks like derivedFrom needs to be checked for nullptr, see http://cppcheck1.osuosl.org:8000/crash.html
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.
For check operatorEqVarError (members variables missing in an
operator=), I cppcheck bails out when a member function without a body is encountered, reasoning that that function might initialize some/all member variables.However, I feel it bails out a bit too soon:
constorstatic, it will probably not initialize member variables (although member variables could bemutableand thus be initialized in aconstfunction; and a static function could be passed*thisto initialize members, although this latter case isn't any different than calling any free function, in which case currently cppcheck doesn't bail out).operator=of a base class is called, I think it is fair to say the base class will initialize its own members (and of its subsequent base classes), but it shall not initialize members of the current object (although it is possible via a virtual function call, but then why are you implementingoperator=when the base class takes care of it?)Maybe some of these cases should be marked as inconclusive? I didn't yet look into that...