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

Maybe-uninitialized variables in Alignment/OfflineValidation/macros/momentumBiasValidation.C #43775

Closed
iarspider opened this issue Jan 23, 2024 · 6 comments · Fixed by #43792
Closed

Comments

@iarspider
Copy link
Contributor

In CMSSW_14_0_CPP20_X_2024-01-22-1100 IB, the following warnings about potentially uninitialized variables are emitted:

  <...>: warning: 'lowLim' may be used uninitialized [-Wmaybe-uninitialized]
    97 |     { return ::new((void*)__location) _Tp(std::forward<_Args>(__args)...); }
      |              ^
<...>/Alignment/OfflineValidation/macros/momentumBiasValidation.C: In function 'extractgausparams':
<...>/Alignment/OfflineValidation/macros/momentumBiasValidation.C:43:12: note: 'lowLim' was declared here
   43 |     double lowLim;
      |            ^
  <...>: warning: 'upLim' may be used uninitialized [-Wmaybe-uninitialized]
    97 |     { return ::new((void*)__location) _Tp(std::forward<_Args>(__args)...); }
      |              ^
<...>/Alignment/OfflineValidation/macros/momentumBiasValidation.C: In function 'extractgausparams':
<...>/Alignment/OfflineValidation/macros/momentumBiasValidation.C:44:12: note: 'upLim' was declared here
   44 |     double upLim;
      |            ^
@iarspider
Copy link
Contributor Author

assign Alignment/OfflineValidation

@cmsbuild
Copy link
Contributor

New categories assigned: alca

@saumyaphor4252,@perrotta,@consuegs you have been requested to review this Pull request/Issue and eventually sign? Thanks

@cmsbuild
Copy link
Contributor

cms-bot internal usage

@cmsbuild
Copy link
Contributor

A new Issue was created by @iarspider .

@Dr15Jones, @sextonkennedy, @smuzaffar, @rappoccio, @makortel, @antoniovilela can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@perrotta
Copy link
Contributor

@iarspider lowLim and upLim will never be uninitialized, because the loop that defines them (starting in https://github.com/cms-sw/cmssw/blob/master/Alignment/OfflineValidation/macros/momentumBiasValidation.C#L50) would at least be run once (when iteration = 0).

Of course, if we want to shut up the warning a whatever initial value can be given to those two variables, but nothing will change in the flow of the macro.

@mmusich
Copy link
Contributor

mmusich commented Jan 23, 2024

@perrotta already correctly analyzed the situation at #43775 (comment).
I'd propose something like

diff --git a/Alignment/OfflineValidation/macros/momentumBiasValidation.C b/Alignment/OfflineValidation/macros/momentumBiasValidation.C
index 06b3069a5a7..b48833be321 100644
--- a/Alignment/OfflineValidation/macros/momentumBiasValidation.C
+++ b/Alignment/OfflineValidation/macros/momentumBiasValidation.C
@@ -40,8 +40,8 @@ namespace eop {
     double mean = f1->GetParameter(1);
     double deviation = f1->GetParameter(2);
 
-    double lowLim;
-    double upLim;
+    double lowLim{mean - (2.0 * deviation)};
+    double upLim{mean + (2.0 * deviation)};
     double newmean;
 
     double degrade = 0.05;

just to silence the warnings ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants