From: David Wells Date: Sat, 25 May 2024 20:20:54 +0000 (-0400) Subject: Avoid a 'possibly dangling reference' warning. X-Git-Tag: v9.6.0-rc1~218^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76e7825f4171f764c8575eab7bd4ba5096dbfa4e;p=dealii.git Avoid a 'possibly dangling reference' warning. --- 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;