From 8bbbefa38f80e7faa6766b4dbe865e8737cda840 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 7 Jun 2022 17:46:14 -0500 Subject: [PATCH] base/polynomials_bdm.cc: avoid a compiler warning with gcc-12 gcc-12 in release mode will inline the evaluate function into some methods of the FE_BDM class. It then rightfully complains that the (now modified) else branch will write out of bounds. Despite the fact that we instantiate this polynomials class and the related FE class for 1d this code has never worked. Thus, fail prominently with an error message. --- source/base/polynomials_bdm.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/base/polynomials_bdm.cc b/source/base/polynomials_bdm.cc index 0fc44c86b0..e4bd9dadee 100644 --- a/source/base/polynomials_bdm.cc +++ b/source/base/polynomials_bdm.cc @@ -122,7 +122,15 @@ PolynomialsBDM::evaluate( std::vector> monovali(dim, std::vector(4)); std::vector> monovalk(dim, std::vector(4)); - if (dim == 2) + if (dim == 1) + { + // Despite the fact that we are instantiating this class for 1, 2 and + // 3 space dimensions we only support dimension 2 and 3. + Assert(false, + dealii::ExcMessage("PolynomialsBDF::evaluate is only " + "available for dim == 2, or dim == 3")); + } + else if (dim == 2) { for (unsigned int d = 0; d < dim; ++d) monomials[0].value(unit_point(d), monovali[d]); @@ -164,7 +172,7 @@ PolynomialsBDM::evaluate( grad_grads[start + 1][1][1][1] = -monovali[1][2]; } } - else // dim == 3 + else if (dim == 3) { // The number of curls in each component. Note that the table in // BrezziFortin91 has a typo, but the text has the right basis @@ -182,6 +190,7 @@ PolynomialsBDM::evaluate( monomials[this->degree() - 1 - i].value(unit_point(d), monovalk[d]); } + if (values.size() != 0) { // x p'(y) q(z) @@ -205,6 +214,7 @@ PolynomialsBDM::evaluate( values[start + 2][0] = -monovali[0][0] * monovalk[1][0]; values[start + 2][1] = 0.; } + if (grads.size() != 0) { grads[start][0][0] = monovali[1][1] * monovalk[2][0]; @@ -243,6 +253,7 @@ PolynomialsBDM::evaluate( grads[start + 2][1][0] = 0.; grads[start + 2][1][1] = 0.; } + if (grad_grads.size() != 0) { grad_grads[start][0][0][0] = 0.; -- 2.39.5