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

Work around a GCC-12 warning about array accesses. #14029

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/deal.II/grid/reference_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -1322,8 +1325,8 @@ ReferenceCell::standard_vertex_to_face_and_vertex_index(
}
else if (*this == ReferenceCells::Triangle)
{
static const ndarray<unsigned int, 3, 2> table = {
{{{0, 0}}, {{0, 1}}, {{1, 1}}}};
static const ndarray<unsigned int, 6, 2> table = {
{{{0, 0}}, {{0, 1}}, {{1, 1}}, {{X, X}}, {{X, X}}, {{X, X}}}};

return table[vertex];
}
Expand All @@ -1333,15 +1336,15 @@ ReferenceCell::standard_vertex_to_face_and_vertex_index(
}
else if (*this == ReferenceCells::Tetrahedron)
{
static const ndarray<unsigned int, 4, 2> table = {
{{{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 2}}}};
static const ndarray<unsigned int, 6, 2> table = {
{{{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 2}}, {{X, X}}, {{X, X}}}};

return table[vertex];
}
else if (*this == ReferenceCells::Pyramid)
{
static const ndarray<unsigned int, 5, 2> table = {
{{{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}}};
static const ndarray<unsigned int, 6, 2> table = {
{{{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{X, X}}}};

return table[vertex];
}
Expand Down