Skip to content
Snippets Groups Projects
Commit 207d6bb5 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[!775] SIMD test: fix implicit this capture warnings

Merge branch 'fix-implicit-this-capture' into 'master'

ref:core/dune-common C++20 deprecates implicit capture of this using [=], and
gcc9 warns about that. Unfortunately, in C++ before 20 listing this together
with a capture-default of = is illegal, and GCC 8 emits a warning about that
that apparently can't be silenced. So the only option if we want to appease
both pre- and post-C++20 is to list each entity to be captures explicitly.
Luckily, that is not too hard in this case.

See [https://gitlab.dune-project.org/core/dune-common/-/jobs/139584\#L486]
(debian:11 gcc-9-20):

    [ 40%] Building CXX object dune/common/CMakeFiles/dunecommon.dir/simd/test.cc.o
    In file included from /builds/core/dune-common/dune/common/simd/test.cc:6:
    /builds/core/dune-common/dune/common/simd/test.hh: In lambda function:
    /builds/core/dune-common/dune/common/simd/test.hh:334:36: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated]
      334 |         Hybrid::forEach(Rebinds{}, [=](auto target) {
          |                                    ^
    /builds/core/dune-common/dune/common/simd/test.hh:334:36: note: add explicit 'this' or '*this' capture

WIP:

-   [x] Check these warnings are really gone in the CI

See merge request [!775]

  [https://gitlab.dune-project.org/core/dune-common/-/jobs/139584\#L486]: https://gitlab.dune-project.org/core/dune-common/-/jobs/139584#L486
  [!775]: gitlab.dune-project.org/core/dune-common/merge_requests/775
parents 504bd2d4 5a14116e
Branches
Tags
1 merge request!775SIMD test: fix implicit this capture warnings
Pipeline #24640 passed
......@@ -331,7 +331,7 @@ namespace Dune {
template<class> class RebindAccept, class Recurse>
void checkRebindOf(Recurse recurse)
{
Hybrid::forEach(Rebinds{}, [=](auto target) {
Hybrid::forEach(Rebinds{}, [this,recurse](auto target) {
using T = typename decltype(target)::type;
// check that the rebound type exists
......@@ -1942,8 +1942,8 @@ namespace Dune {
}
template<class V> void UnitTest::checkUnaryOps()
{
auto checkMask = [=](auto id) {
auto check = [=](auto op) {
auto checkMask = [this](auto id) {
auto check = [this,id](auto op) {
id(this)->template checkUnaryOpsV<V>(op);
};
......@@ -1963,8 +1963,8 @@ namespace Dune {
// check(OpPrefixBitNot{});
};
auto checkVector = [=](auto id) {
auto check = [=](auto op) {
auto checkVector = [this](auto id) {
auto check = [this,id](auto op) {
id(this)->template checkUnaryOpsV<V>(op);
};
......@@ -1994,8 +1994,8 @@ namespace Dune {
}
template<class V> void UnitTest::checkBinaryOpsVectorVector()
{
auto checker = [=](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [=](auto t1, auto t2) {
auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [this,op](auto t1, auto t2) {
this->checkBinaryOpVV(t1, t2, op);
};
this->checkBinaryRefQual<V, V, doVV>(check);
......@@ -2004,13 +2004,13 @@ namespace Dune {
}
template<class V> void UnitTest::checkBinaryOpsScalarVector()
{
auto checker = [=](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [=](auto t1, auto t2) {
auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [this,op](auto t1, auto t2) {
this->checkBinaryOpSV(t1, t2, op);
};
this->checkBinaryRefQual<Scalar<V>, V, doSV>(check);
auto crossCheck = [=](auto t1, auto t2) {
auto crossCheck = [this,op](auto t1, auto t2) {
this->checkBinaryOpVVAgainstSV(t1, t2, op);
};
this->checkBinaryRefQual<Scalar<V>, V, doSV && doVV>(crossCheck);
......@@ -2019,13 +2019,13 @@ namespace Dune {
}
template<class V> void UnitTest::checkBinaryOpsVectorScalar()
{
auto checker = [=](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [=](auto t1, auto t2) {
auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [this,op](auto t1, auto t2) {
this->checkBinaryOpVS(t1, t2, op);
};
this->checkBinaryRefQual<V, Scalar<V>, doVS>(check);
auto crossCheck = [=](auto t1, auto t2) {
auto crossCheck = [this,op](auto t1, auto t2) {
this->checkBinaryOpVVAgainstVS(t1, t2, op);
};
this->checkBinaryRefQual<V, Scalar<V>, doVV && doVS>(crossCheck);
......@@ -2034,8 +2034,8 @@ namespace Dune {
}
template<class V> void UnitTest::checkBinaryOpsProxyVector()
{
auto checker = [=](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [=](auto t1, auto t2) {
auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [this,op](auto t1, auto t2) {
this->checkBinaryOpPV(t1, t2, op);
};
this->checkBinaryRefQual<V, V, doSV>(check);
......@@ -2044,8 +2044,8 @@ namespace Dune {
}
template<class V> void UnitTest::checkBinaryOpsVectorProxy()
{
auto checker = [=](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [=](auto t1, auto t2) {
auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
auto check = [this,op](auto t1, auto t2) {
this->checkBinaryOpVP(t1, t2, op);
};
this->checkBinaryRefQual<V, V, doVS>(check);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment