From 3a393d85409649a763734e0fe56fbcd2e6701913 Mon Sep 17 00:00:00 2001 From: David Wells Date: Tue, 21 Jun 2022 09:41:19 -0400 Subject: [PATCH] Work around a GCC-12 warning about array accesses. This only occurs at higher optimization levels with -Warray-bounds. --- include/deal.II/grid/reference_cell.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index e27120347d..8d30f42b49 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -1311,6 +1311,9 @@ ReferenceCell::standard_vertex_to_face_and_vertex_index( const unsigned int vertex) const { AssertIndexRange(vertex, n_vertices()); + // Work around a GCC warning at higher optimization levels by making all of + // these tables the same size + constexpr unsigned int X = numbers::invalid_unsigned_int; if (*this == ReferenceCells::Vertex) { @@ -1322,8 +1325,8 @@ ReferenceCell::standard_vertex_to_face_and_vertex_index( } else if (*this == ReferenceCells::Triangle) { - static const ndarray table = { - {{{0, 0}}, {{0, 1}}, {{1, 1}}}}; + static const ndarray table = { + {{{0, 0}}, {{0, 1}}, {{1, 1}}, {{X, X}}, {{X, X}}, {{X, X}}}}; return table[vertex]; } @@ -1333,15 +1336,15 @@ ReferenceCell::standard_vertex_to_face_and_vertex_index( } else if (*this == ReferenceCells::Tetrahedron) { - static const ndarray table = { - {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 2}}}}; + static const ndarray table = { + {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 2}}, {{X, X}}, {{X, X}}}}; return table[vertex]; } else if (*this == ReferenceCells::Pyramid) { - static const ndarray table = { - {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}}}; + static const ndarray table = { + {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{X, X}}}}; return table[vertex]; } -- 2.39.5