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

Add -Wno-dangling-reference when using GCC #9

Merged
merged 1 commit into from
Sep 24, 2024
Merged

Conversation

jmcarcell
Copy link
Member

@jmcarcell jmcarcell commented Sep 24, 2024

After the inclusion of GCC 14 in the stack, some warnings have appeared when calling some functions in DD4hep that return const &. From what I understand, in these cases this warning is a false positive because the compiler doesn't have access to the implementation of the functions so it can't know there isn't a dangling reference to a temporary (after all the warning only says "possibly"). I suggest removing it. There is also a way of suppressing the warnings in DD4hep with attributes, but then all the affected functions would need it and that can be easily overlooked after adding or changing one while also making the code uglier. This is one example of the warning:

/k4geo/detectorCommon/src/DetUtils_k4geo.cpp:480:15: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  480 |   const auto& transformMatrix = detelement.nominal().worldTransformation();
      |               ^~~~~~~~~~~~~~~
/k4geo/detectorCommon/src/DetUtils_k4geo.cpp:480:73: note: the temporary was destroyed at the end of the full expression 'detelement.dd4hep::DetElement::nominal().dd4hep::Alignment::worldTransformation()'
  480 |   const auto& transformMatrix = detelement.nominal().worldTransformation();

Since this is breaking CI in some places (because of -Werror), I'll merge and push the changes soon if there aren't any complains.

@jmcarcell jmcarcell merged commit 8461abe into main Sep 24, 2024
@jmcarcell jmcarcell deleted the dangling-ref branch September 24, 2024 16:43
jmcarcell added a commit to key4hep/EDM4hep that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4Clue that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4EDM4hep2LcioConv that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4FWCore that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4geo that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4MarlinWrapper that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4SimDelphes that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4ActsTracking that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4-project-template that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4Reco that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4RecTracker that referenced this pull request Sep 24, 2024
jmcarcell added a commit to key4hep/k4GaudiPandora that referenced this pull request Sep 24, 2024
Victor-Schwan pushed a commit to Victor-Schwan/k4geo that referenced this pull request Sep 25, 2024
Victor-Schwan pushed a commit to Victor-Schwan/k4geo that referenced this pull request Oct 15, 2024
forthommel pushed a commit to forthommel/k4ActsTracking that referenced this pull request Nov 14, 2024
AuroraPerego pushed a commit to AuroraPerego/k4Clue that referenced this pull request Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant