]> https://gitweb.dealii.org/ - dealii.git/commitdiff
base/tensor.h: work around bogus compiler warning 16499/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 18 Jan 2024 23:09:04 +0000 (17:09 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 18 Jan 2024 23:12:19 +0000 (17:12 -0600)
gcc-9.4 warnings loudly about an unused argument "end":

```
In file included from ../include/deal.II/base/symmetric_tensor.h:26,
                 from ../include/deal.II/base/array_view.h:23,
                 from ../source/base/tensor.cc:16:
../include/deal.II/base/tensor.h: In instantiation of 'void dealii::Tensor<rank_, dim, Number>::unroll(Iterator, Iterator) const [with Iterator = float*; int rank_ = 1; int dim = 1; Number = float]':
../include/deal.II/base/tensor.h:1736:11:   required from 'void dealii::Tensor<rank_, dim, Number>::unroll(Iterator, Iterator) const [with Iterator = float*; int rank_ = 2; int dim = 1; Number = float]'
../source/base/tensor.cc:52:5:   required from 'void dealii::{anonymous}::calculate_svd_in_place(dealii::Tensor<2, dim, Number>&, dealii::Tensor<2, dim, Number>&) [with int dim = 1; Number = float]'
../source/base/tensor.cc:85:25:   required from 'dealii::Tensor<2, dim, Number> dealii::project_onto_orthogonal_tensors(const dealii::Tensor<2, dim, Number>&) [with int dim = 1; Number = float]'
../source/base/tensor.cc:92:60:   required from here
../include/deal.II/base/tensor.h:1728:51: warning: parameter 'end' set but not used [-Wunused-but-set-parameter]
 1728 |                                    const Iterator end) const
      |
```

This is of course bogus, the compiler simply lost track of the
`if constexpr(...)` branch. This is fixed in later gcc versions. Let's
simply use the usual `(void)parameter` strategy to make gcc-9.4 happy.

include/deal.II/base/tensor.h

index a452ce5411b297ef5652ee1008107581365e60b7..a6aed73afe060986628103445963409daf5194d0 100644 (file)
@@ -1871,6 +1871,7 @@ Tensor<rank_, dim, Number>::unroll(const Iterator begin,
       // For rank-1 tensors, we can simply copy the current elements from
       // our linear array into the output range, and then return the
       // iterator moved forward by 'dim' elements:
+      (void)end;
       Assert(std::distance(begin, end) >= dim,
              ExcMessage(
                "The provided iterator range must contain at least 'dim' "

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.