]> https://gitweb.dealii.org/ - dealii.git/commit
matrix_free/fe_evaluation.h: avoid a warning with g++-13
authorMatthias Maier <tamiko@43-1.org>
Thu, 6 Jul 2023 22:16:06 +0000 (17:16 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 6 Jul 2023 22:22:32 +0000 (17:22 -0500)
commit935544d7e6a32d9e7986bfff6f42f43a7bc89386
tree3c1de8d263aeb55be7457265f792949d3b32f0b4
parentaebed96336bfcb8516ff75037b4c558051d60e5d
matrix_free/fe_evaluation.h: avoid a warning with g++-13

g++-13 is a bit too eager to warn about an array bounds violation here
after its optimizer pass introduced a `__builtin_memset()`:
```
In file included from include/deal.II/matrix_free/operators.h:30,
                 from include/deal.II/numerics/vector_tools_project.templates.h:36,
                 from source/numerics/vector_tools_project_qpmf.cc:17:
                 In member function ‘void dealii::FEEvaluationBase<...>:
                 inlined from ‘void dealii::FEEvaluationBase<...>:
include/deal.II/matrix_free/fe_evaluation.h:3937:20: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ offset [20, 1020] is out of the bounds [0, 16] of object ‘dof_indices’ with type ‘std::array<unsigned int, 4>’ [-Warray-bounds=]
 3937 |     dof_indices[v] = numbers::invalid_unsigned_int;
      |     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
which is a bit silly as the statement reads:
```
// implied Assert(n_filled_lanes <= n_lanes, ExcInternalError());
for (unsigned int v = n_filled_lanes; v < n_lanes; ++v)
  dof_indices[v] = numbers::invalid_unsigned_int;
```
So instead let's simply initialize all elements of `dof_indices` to
`numbers::invalid_unsigned_int` via `std::fill` instead. I doubt that
this has much performance influence in practice as it gets replaced by a
`__builtin_memset()` right away.
include/deal.II/matrix_free/fe_evaluation.h

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.