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

RecoTracker/MeasurementDet : bug fix for gcc 6.0 misleading-indentation warning #15003

Merged
merged 3 commits into from Jul 9, 2016
Merged

RecoTracker/MeasurementDet : bug fix for gcc 6.0 misleading-indentation warning #15003

merged 3 commits into from Jul 9, 2016

Conversation

gartung
Copy link
Member

@gartung gartung commented Jun 27, 2016

/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/plugins/TkStripMeasurementDet.cc:83:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
^~~
/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/plugins/TkStripMeasurementDet.cc:83:81: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'
for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
^~~
/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/plugins/TkStripMeasurementDet.cc:90:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
^~~
/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/plugins/TkStripMeasurementDet.cc:90:79: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'
for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
^~~

/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc:29:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (bad128Strip_[j+offset] == false) hasAny128StripBad_[i] = false; break;
^~
/build/cmsbuild/jenkins-workarea/workspace/build-any-ib/w/tmp/BUILDROOT/8258e37281729e179b5af9c3b033d930/opt/cmssw/slc6_amd64_gcc600/cms/cmssw/CMSSW_8_1_X_2016-06-26-2300/src/RecoTracker/MeasurementDet/src/TkMeasurementDetSet.cc:29:72: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
if (bad128Strip_[j+offset] == false) hasAny128StripBad_[i] = false; break;
^~~~~

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @gartung (Patrick Gartung) for CMSSW_8_1_X.

It involves the following packages:

RecoTracker/MeasurementDet

@cmsbuild, @cvuosalo, @slava77, @davidlange6 can you please review it and eventually sign? Thanks.
@ghellwig, @makortel, @GiacomoSguazzoni, @rovere, @VinInn, @mschrode, @gpetruc, @dgulhan this is something you requested to watch as well.
@slava77, @Degano, @smuzaffar you are the release manager for this.

cms-bot commands are list here #13028

@slava77
Copy link
Contributor

slava77 commented Jun 27, 2016

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 27, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/13706/console

@cmsbuild
Copy link
Contributor

@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2016

since when line breaking and indentation have a meaning in C(++)????

@cmsbuild
Copy link
Contributor

@gartung
Copy link
Member Author

gartung commented Jun 28, 2016

Did the author mean to enclose the line in curly braces?

@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2016

of course not!

@gartung
Copy link
Member Author

gartung commented Jun 28, 2016

I don't know that. The warning is to catch the case where the author meant to enclose in curly braces.

@gartung
Copy link
Member Author

gartung commented Jun 28, 2016

@Dr15Jones care to comment.

hasAny128StripBad_[i] = true;
for (int j = 0; i < (totalStrips_[j] >> 7); j++) {
if (bad128Strip_[j+offset] == false) hasAny128StripBad_[i] = false;
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually make sense, although matches what the previous version was doing. This code always stops after the first iteration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better fix the bug and not loose the warning that points to a problem.
It may make more sense if someone (@VinInn ?) take over.
In the case the bug is fixed, the title of the PR should be changed.

@Dr15Jones
Copy link
Contributor

@VinInn the gcc 6 compiler prints warnings when one doesn't use braces for an if and then add additional lines after the first semi-colon. These types of lines were found to often be a source of bugs. In fact, it looks like this actually caught a bug in this code.

@Dr15Jones
Copy link
Contributor

@slava77 How does this bug (i.e. the break not actually being in the if) affect reconstruction?

@gartung
Copy link
Member Author

gartung commented Jun 28, 2016

@Dr15Jones I started adding curly braces where I thought they should go but then changed to just adding line breaks. In some cases I can't tell what the author meant.

@Dr15Jones
Copy link
Contributor

@VinInn Definitely the tmp.clear() should not be in the same block as the for loop. But why is there a break in a for loop if that loop always calls the break? If that is the intended behavior shouldn't the loop just be removed?

@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2016

@Dr15Jones ,
comment says, // this should not happen, as usually you turn on all fibers
so most probably is never run

@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2016

the compiler most probably remove the loop!
IN any case I think it is a bug, curly braces should be added there...
(the code is oldish)

@gartung gartung changed the title Fix this 'if' clause does not guard... [-Wmisleading-indentation] gcc 6.0 misleading-indentation warning flags potential bug Jun 28, 2016
@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2016

@cmsbuild , please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 28, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/13737/console

@gartung gartung changed the title gcc 6.0 misleading-indentation warning flags potential bug RecoTracker/MeasurementDet : gcc 6.0 misleading-indentation warning flags potential bug; with formatting and bug fix Jun 28, 2016
@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@gartung gartung changed the title RecoTracker/MeasurementDet : gcc 6.0 misleading-indentation warning flags potential bug; with formatting and bug fix RecoTracker/MeasurementDet : formatting fix for gcc 6.0 misleading-indentation warning Jul 1, 2016
@cvuosalo
Copy link
Contributor

cvuosalo commented Jul 1, 2016

@gartung: I don't understand your latest change to the PR title. This PR potentially changes run-time behavior in TkMeasurementDetSet.cc by moving the break under the if. The title should mention this bug fix.

@gartung gartung changed the title RecoTracker/MeasurementDet : formatting fix for gcc 6.0 misleading-indentation warning RecoTracker/MeasurementDet : bug fix for gcc 6.0 misleading-indentation warning Jul 1, 2016
@gartung
Copy link
Member Author

gartung commented Jul 1, 2016

Sorry. Pasted the wrong title change.

@cvuosalo
Copy link
Contributor

cvuosalo commented Jul 6, 2016

+1

For #15003 95336ed

Cleaning up confusing indentation in two TkStripMeasurementDet files. One change is actually a bug fix, but it is in a section of code that was probably never actually executed, so the fix shouldn't change normal run-time behavior. There should be no change in monitored quantities.

The code changes are satisfactory, and Jenkins tests against baseline CMSSW_8_1_X_2016-06-28-1100 show no significant differences, as expected.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jul 6, 2016

This pull request is fully signed and it will be integrated in one of the next CMSSW_8_1_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @slava77, @davidlange6, @Degano, @smuzaffar

@davidlange6 davidlange6 merged commit b64a650 into cms-sw:CMSSW_8_1_X Jul 9, 2016
@gartung gartung deleted the RecoTracker-MeasurementDet-fix-indent-not-guard-warn branch July 20, 2016 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants