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

base/tensor.h: work around bogus compiler warning #16499

Merged
merged 1 commit into from Jan 19, 2024

Conversation

tamiko
Copy link
Member

@tamiko tamiko commented Jan 18, 2024

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.

In reference to #16491 (for tracking purposes).
Closes #16491

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.
@tamiko
Copy link
Member Author

tamiko commented Jan 18, 2024

@bangerth fyi.

@tamiko tamiko added this to the Release 9.6 milestone Jan 18, 2024
Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@marcfehling marcfehling merged commit 86403ab into dealii:master Jan 19, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression tester regressed 9c9a7d
3 participants