From: David Wells Date: Tue, 21 Jun 2022 13:41:19 +0000 (-0400) Subject: Work around a GCC-12 warning about array accesses. X-Git-Tag: v9.4.0-rc2~2^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3569da4bb205d0285efe01039c0c17fd1cec36d;p=dealii.git Work around a GCC-12 warning about array accesses. This only occurs at higher optimization levels with -Warray-bounds. --- 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]; }