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

step-70: warning: possibly dangling reference to a temporary [-Wdangling-reference] #15298

Closed
marcfehling opened this issue Jun 4, 2023 · 1 comment · Fixed by #15299
Closed
Milestone

Comments

@marcfehling
Copy link
Member

I built the library with the component examples recently with gcc 13.1.1 and I got the following warning for step-70:

Building CXX object examples/CMakeFiles/example_step_70_debug.dir/step-70/step-70.cc.o
dealii/examples/step-70/step-70.cc: In instantiation of ‘void Step70::StokesImmersedProblem<dim, spacedim>::assemble_nitsche_restriction() [with int dim = 2; int spacedim = 3]’:
dealii/examples/step-70/step-70.cc:1869:9:   required from ‘void Step70::StokesImmersedProblem<dim, spacedim>::run() [with int dim = 2; int spacedim = 3]’
dealii/examples/step-70/step-70.cc:1938:22:   required from here
dealii/examples/step-70/step-70.cc:1484:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                         ^~~
dealii/examples/step-70/step-70.cc:1484:52: note: the temporary was destroyed at the end of the full expression ‘(& p)->dealii::Particles::ParticleAccessor<3, 3>::get_properties().dealii::ArrayView<const double>::operator[](0)’
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                                  ~~~~~~~~~~~~~~~~~~^
dealii/examples/step-70/step-70.cc: In instantiation of ‘void Step70::StokesImmersedProblem<dim, spacedim>::assemble_nitsche_restriction() [with int dim = 3; int spacedim = 3]’:
dealii/examples/step-70/step-70.cc:1869:9:   required from ‘void Step70::StokesImmersedProblem<dim, spacedim>::run() [with int dim = 3; int spacedim = 3]’
dealii/examples/step-70/step-70.cc:1946:22:   required from here
dealii/examples/step-70/step-70.cc:1484:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                         ^~~
dealii/examples/step-70/step-70.cc:1484:52: note: the temporary was destroyed at the end of the full expression ‘(& p)->dealii::Particles::ParticleAccessor<3, 3>::get_properties().dealii::ArrayView<const double>::operator[](0)’
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                                  ~~~~~~~~~~~~~~~~~~^
dealii/examples/step-70/step-70.cc: In instantiation of ‘void Step70::StokesImmersedProblem<dim, spacedim>::assemble_nitsche_restriction() [with int dim = 2; int spacedim = 2]’:
dealii/examples/step-70/step-70.cc:1869:9:   required from ‘void Step70::StokesImmersedProblem<dim, spacedim>::run() [with int dim = 2; int spacedim = 2]’
dealii/examples/step-70/step-70.cc:1954:22:   required from here
dealii/examples/step-70/step-70.cc:1484:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                         ^~~
dealii/examples/step-70/step-70.cc:1484:52: note: the temporary was destroyed at the end of the full expression ‘(& p)->dealii::Particles::ParticleAccessor<2, 2>::get_properties().dealii::ArrayView<const double>::operator[](0)’
 1484 |             const auto &JxW    = p.get_properties()[0];
      |                                  ~~~~~~~~~~~~~~~~~~^
@marcfehling marcfehling added this to the Release 9.5 milestone Jun 4, 2023
@bangerth
Copy link
Member

bangerth commented Jun 4, 2023

Yes, good catch. I have a patch.

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 a pull request may close this issue.

2 participants