[RFC] cleanup of frequent shadow warnings
While compiling with -Wshadow for a test I decided to cleanup some of the more frequent cases exposed mainly by being present in interface/.
Perhaps this can be a step towards enabling this warning in our builds.
One curious case was the use of CLHEP/Units/GlobalSystemOfUnits.h, which puts a few singe character (m, s, g) and other short-name symbols in the global scope. The scoped SystemOfUnits.h seems to be more appropriate for a large sw project.
The total count of warnings goes down from 48.6K to 14K.
cms-bot internal usage
-code-checks
Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40105
- This PR adds an extra 164KB to repository
Code check has found code style and quality issues which could be resolved by applying following patch(s)
- code-format:
https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40105/code-format.patch
e.g.
curl -k https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40105/code-format.patch | patch -p1You can also runscram build code-formatto apply code format directly
+code-checks
Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40106
- This PR adds an extra 236KB to repository
A new Pull Request was created by @slava77 for master.
It involves the following packages:
- DataFormats/BTauReco (reconstruction)
- DataFormats/Common (core)
- DataFormats/PatCandidates (xpog, reconstruction)
- DataFormats/SoATemplate (heterogeneous)
- DataFormats/VertexReco (reconstruction)
- FWCore/Framework (core)
- Geometry/CommonTopologies (geometry)
- Geometry/HcalCommonData (geometry)
- HeterogeneousCore/AlpakaInterface (heterogeneous)
- HeterogeneousCore/CUDAUtilities (heterogeneous)
- OnlineDB/EcalCondDB (db)
- PhysicsTools/MVAComputer (ml)
- RecoBTag/FeatureTools (reconstruction)
- RecoLocalTracker/SiPixelClusterizer (reconstruction)
- SimG4CMS/Calo (simulation)
- SimTracker/SiPhase2Digitizer (simulation, upgrade)
- TrackPropagation/Geant4e (simulation)
- Validation/GlobalHits (dqm)
- Validation/HcalHits (dqm)
@wpmccormack, @saumyaphor4252, @mandrenguyen, @fwyzard, @srimanob, @cmsbuild, @hqucms, @jfernan2, @civanch, @rvenditti, @francescobrivio, @Dr15Jones, @perrotta, @nothingface0, @bsunanda, @vlimant, @subirsarkar, @smuzaffar, @consuegs, @syuvivida, @antoniovagnerini, @makortel, @mdhildreth, @valsdav, @tjavaid can you please review it and eventually sign? Thanks. @felicepantaleo, @dkotlins, @slomeo, @abdoulline, @argiro, @hatakeyamak, @castaned, @dgulhan, @Ming-Yan, @mroguljic, @VinInn, @AlexDeMoor, @ReyerBand, @gouskos, @demuller, @wddgit, @rsreds, @hqucms, @yuanchao, @rchatter, @andrzejnovak, @VourMa, @PonIlya, @GiacomoSguazzoni, @tvami, @JanChyczynski, @Senphy, @tsusa, @rovere, @bsunanda, @missirol, @fabiocos, @JanFSchulte, @mtosi, @gpetruc, @mmusich, @thomreis, @ferencek, @makortel, @wang0jin, @threus this is something you requested to watch as well. @rappoccio, @antoniovilela, @sextonkennedy you are the release manager for this.
cms-bot commands are listed here
@cmsbuild please test
-1
Failed Tests: UnitTests
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-631d6d/39120/summary.html
COMMIT: 2344e8df211fb31f4ed4a5687b04bb1c8c993f91
CMSSW: CMSSW_14_1_X_2024-04-26-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/44855/39120/install.sh to create a dev area with all the needed externals and cmssw changes.
Unit Tests
I found 4 errors in the following unit tests:
---> test testHeterogeneousCoreCUDATestWriteRead had ERRORS ---> test testHeterogeneousCoreAlpakaTestWriteReadSerialSync had ERRORS ---> test testHeterogeneousCoreAlpakaTestModulesCPU had ERRORS and more ...
Comparison Summary
There are some workflows for which there are errors in the baseline: 24834.78 step 2 The results for the comparisons for these workflows could be incomplete This means most likely that the IB is having errors in the relvals.The error does NOT come from this pull request
Summary:
- You potentially removed 147 lines from the logs
- Reco comparison results: 56 differences found in the comparisons
- DQMHistoTests: Total files compared: 49
- DQMHistoTests: Total histograms compared: 3433373
- DQMHistoTests: Total failures: 9
- DQMHistoTests: Total nulls: 0
- DQMHistoTests: Total successes: 3433344
- DQMHistoTests: Total skipped: 20
- DQMHistoTests: Total Missing objects: 0
- DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
- Checked 206 log files, 170 edm output root files, 49 DQM output files
- TriggerResults: no differences found
+code-checks
Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40111
- This PR adds an extra 428KB to repository
Pull request #44855 was updated. @smuzaffar, @mandrenguyen, @srimanob, @tjavaid, @saumyaphor4252, @antoniovagnerini, @civanch, @hqucms, @jfernan2, @valsdav, @consuegs, @vlimant, @cmsbuild, @nothingface0, @wpmccormack, @rvenditti, @francescobrivio, @bsunanda, @Dr15Jones, @mdhildreth, @syuvivida, @makortel, @subirsarkar, @perrotta, @fwyzard can you please check and sign again.
@cmsbuild please test
+1
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-631d6d/39126/summary.html
COMMIT: 3b6ed17a0bcc05fddce9fc33b24e344841db1b8c
CMSSW: CMSSW_14_1_X_2024-04-26-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/44855/39126/install.sh to create a dev area with all the needed externals and cmssw changes.
Comparison Summary
There are some workflows for which there are errors in the baseline: 24834.78 step 2 The results for the comparisons for these workflows could be incomplete This means most likely that the IB is having errors in the relvals.The error does NOT come from this pull request
Summary:
- You potentially removed 117 lines from the logs
- Reco comparison results: 51 differences found in the comparisons
- DQMHistoTests: Total files compared: 49
- DQMHistoTests: Total histograms compared: 3433373
- DQMHistoTests: Total failures: 6
- DQMHistoTests: Total nulls: 0
- DQMHistoTests: Total successes: 3433347
- DQMHistoTests: Total skipped: 20
- DQMHistoTests: Total Missing objects: 0
- DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
- Checked 206 log files, 170 edm output root files, 49 DQM output files
- TriggerResults: no differences found
+db
- Why not?
-heterogeneous
I'm personally not in favour of these changes. Some are false positives, and many make the code less intuitive and more complicated to read.
@slava77 , yes, itis "" --><>. an ideal solution for CLHEP headers is do not use inside header files except the situation when it is unavoidable. In such case to use <CLHEP/Units/SystemOfUnits.h> is the recommendation.
@slava77 , yes, itis "" --><>. an ideal solution for CLHEP headers is do not use inside header files except the situation when it is unavoidable. In such case to use <CLHEP/Units/SystemOfUnits.h> is the recommendation.
thanks for clarifying; I updated the headers now.
files were selected by
git diff --stat --name-only CMSSW_14_1_0_pre2 | grep h$ | while read -r f; do grep -l \"CLHEP/ $f; done
+code-checks
Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44855/40112
-
This PR adds an extra 192KB to repository
-
There are other open Pull requests which might conflict with changes you have proposed:
- File DataFormats/SoATemplate/interface/SoAView.h modified in PR(s): #44858
- File HeterogeneousCore/AlpakaInterface/interface/getDeviceCachingAllocator.h modified in PR(s): #44858
Pull request #44855 was updated. @jfernan2, @vlimant, @makortel, @cmsbuild, @rvenditti, @bsunanda, @Dr15Jones, @syuvivida, @mandrenguyen, @smuzaffar, @tjavaid, @fwyzard, @mdhildreth, @subirsarkar, @civanch, @wpmccormack, @valsdav, @srimanob, @antoniovagnerini, @nothingface0, @hqucms can you please check and sign again.
@cmsbuild please test
+1
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-631d6d/39127/summary.html
COMMIT: 46695cca66ff86843320b201445af84079375e86
CMSSW: CMSSW_14_1_X_2024-04-27-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/44855/39127/install.sh to create a dev area with all the needed externals and cmssw changes.
Comparison Summary
Summary:
- You potentially removed 88 lines from the logs
- Reco comparison results: 50 differences found in the comparisons
- DQMHistoTests: Total files compared: 49
- DQMHistoTests: Total histograms compared: 3433373
- DQMHistoTests: Total failures: 9
- DQMHistoTests: Total nulls: 0
- DQMHistoTests: Total successes: 3433344
- DQMHistoTests: Total skipped: 20
- DQMHistoTests: Total Missing objects: 0
- DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
- Checked 206 log files, 170 edm output root files, 49 DQM output files
- TriggerResults: no differences found
-1
sorry, but for me these changes are simply making the code ~~worse~~ less readable.
@slava77 , may be it is possible to split PR into two: one for "law and order for CLHEP" and another for heterogenous?
"himself" on the subject https://lkml.org/lkml/2006/11/28/253
Anyhow I'm sure you all read this ttps://stackoverflow.com/questions/2958457/gcc-wshadow-is-too-strict and are aware of the possible options to attach to Wshadow (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html) So why "global" has been chosen? would not be better to move to -Wshadow=compatible-local ?
Anyhow for this trivial example (that is surely not doing what the naive author intended)
class foo {
foo(int);
int i;
};
foo::foo(int i) : i(i){
for (int j=0; j<i; ++j)
i++;
}
-Wshadow=local (or compatible-local) will not issue any warning. Only -Wshadow(global) will.
So: do we want to warn for such cases or we consider the authors able to avoid armful shadow of global (actually class-member) variables?
@slava77 , may be it is possible to split PR into two: one for "law and order for CLHEP" and another for heterogenous?
yes; this clearly became an RFC PR
@cms-sw/core-l2 please comment if any of these are useful. Thank you.
@cms-sw/core-l2 please comment if any of these are useful.
Do you mean in the core packages specifically, or in general?
In core packages some of the changes looked useful, some could have been kept as they were (as the scoping was very clear), but I'd rather have the renamed versions than adding #pragma GCC diagnostic.
it looks like there is no significant interest to have fixes other than in CLHEP (done in #44882 )