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

correctedP4 must return a copy of p4() #11311

Merged
merged 1 commit into from Sep 22, 2015

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented Sep 17, 2015

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 David.Abdurachmanov@cern.ch

`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 <David.Abdurachmanov@cern.ch>
@cmsbuild
Copy link
Contributor

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.
@gpetruc this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@Degano you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@gpetruc
Copy link
Contributor

gpetruc commented Sep 17, 2015

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

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@davidlt
Copy link
Contributor Author

davidlt commented Sep 21, 2015

ping^1

@monttj
Copy link
Contributor

monttj commented Sep 22, 2015

+1

@cmsbuild
Copy link
Contributor

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

@davidlange6
Copy link
Contributor

+1

cmsbuild added a commit that referenced this pull request Sep 22, 2015
correctedP4 must return a copy of p4()
@cmsbuild cmsbuild merged commit 16c188d into cms-sw:CMSSW_7_6_X Sep 22, 2015
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

5 participants