From 76e7825f4171f764c8575eab7bd4ba5096dbfa4e Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 25 May 2024 16:20:54 -0400 Subject: [PATCH] Avoid a 'possibly dangling reference' warning. --- source/grid/grid_tools_dof_handlers.cc | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index aca115ca24..4f99ab7f8b 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -270,23 +270,26 @@ namespace GridTools // (possibly) coarser neighbor. if this is the case, // then we need to also add this neighbor if (dim >= 2) - for (const auto face : - cell->reference_cell().faces_for_given_vertex(v)) - if (!cell->at_boundary(face) && - cell->neighbor(face)->is_active()) - { - // there is a (possibly) coarser cell behind a - // face to which the vertex belongs. the - // vertex we are looking at is then either a - // vertex of that coarser neighbor, or it is a - // hanging node on one of the faces of that - // cell. in either case, it is adjacent to the - // vertex, so add it to the list as well (if - // the cell was already in the list then the - // std::set makes sure that we get it only - // once) - adjacent_cells.insert(cell->neighbor(face)); - } + { + const auto reference_cell = cell->reference_cell(); + for (const auto face : + reference_cell.faces_for_given_vertex(v)) + if (!cell->at_boundary(face) && + cell->neighbor(face)->is_active()) + { + // there is a (possibly) coarser cell behind a + // face to which the vertex belongs. the + // vertex we are looking at is then either a + // vertex of that coarser neighbor, or it is a + // hanging node on one of the faces of that + // cell. in either case, it is adjacent to the + // vertex, so add it to the list as well (if + // the cell was already in the list then the + // std::set makes sure that we get it only + // once) + adjacent_cells.insert(cell->neighbor(face)); + } + } // in any case, we have found a cell, so go to the next cell goto next_cell; -- 2.39.5