StBTofCalibMaker: fix variable shadowing#273
Merged
veprbl merged 1 commit intostar-bnl:mainfrom Jan 7, 2022
Merged
Conversation
The code in question looks like this:
int doPID = 0;
for(;;) {
// ...
Bool_t doPID = kFALSE;
// ...
if(!doPID) continue;
doPID++;
}
LOG_INFO << doPID << endm;
The doPID variable from the outer scope gets shadowed by the boolean flag variable. That should make it always report 0.
This was found with a following compiler diagnostic:
.sl79_gcc485/obj/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx: In member function 'void StBTofCalibMaker::processStEvent()':
.sl79_gcc485/obj/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx:1241:14: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
1241 | doPID++;
| ^~
.sl79_gcc485/obj/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx: In member function 'void StBTofCalibMaker::processMuDst()':
.sl79_gcc485/obj/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx:1496:18: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
1496 | doPID++;
| ^~
fgeurts
approved these changes
Jan 6, 2022
Member
fgeurts
left a comment
There was a problem hiding this comment.
That's a good catch. Recent code updates introduced a counter that had the exact same name as a boolean flag that was used inside a loop. The good news is that this shadowing did not have any detrimental to the calibrations as the counter was only used for logging purposes and the boolean "reset" happened inside the loop for each individual track - as originally intended.
starsdong
approved these changes
Jan 7, 2022
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.
The code in question looks like this:
The doPID variable from the outer scope gets shadowed by the boolean flag variable. That should make it always report 0.
This was found with a following compiler diagnostic: