-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
correctedP4 must return a copy of p4() #11311
correctedP4 must return a copy of p4() #11311
Conversation
`correctedJet()` returns a new `Jet` object. In `correctedP4()` we return a reference to p4() on a stack, thus the reference is invalid and most likely value will be changed with the next few function calls. DataFormats/PatCandidates/interface/Jet.h:155:178: error: function returns address of local variable [-Werror=return-local-addr] DataFormats/PatCandidates/interface/Jet.h:158:204: error: function returns address of local variable [-Werror=return-local-addr] A quick fix (this patch) is to make `correctedP4()` return a copy instead of a reference. If `correctedJet()` is on hot path, the new `Jet` object should be cached and then we could also return a reference in `correctedP4()`. Signed-off-by: David Abdurachmanov <[email protected]>
A new Pull Request was created by @davidlt for CMSSW_7_6_X. correctedP4 must return a copy of p4() It involves the following packages: DataFormats/PatCandidates @cmsbuild, @vadler, @monttj can you please review it and eventually sign? Thanks. |
looks right to me in fact, if correctedJet() starts to matter in terms of time, correctedP4() should be implemented in a better way calling the method that computes the correction factor and not the full corrected jet. Giovanni |
ping^1 |
+1 |
This pull request is fully signed and it will be integrated in one of the next CMSSW_7_6_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @smuzaffar |
+1 |
correctedP4 must return a copy of p4()
correctedJet()
returns a newJet
object. IncorrectedP4()
wereturn a reference to p4() on a stack, thus the reference is invalid and
most likely value will be changed with the next few function calls.
A quick fix (this patch) is to make
correctedP4()
return a copyinstead of a reference.
If
correctedJet()
is on hot path, the newJet
object should becached and then we could also return a reference in
correctedP4()
.Signed-off-by: David Abdurachmanov [email protected]