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

[!773] Fix warnings, add comments in fvectorconversion1d.cc test

Merge branch 'fix-warning-add-comments' into 'master'

ref:core/dune-common This is a regression test, the threw up undefined
variable warnings. unsure about the correct fix, I tried to understand the
test. In addition to fixing the warnings, I left some comments too, in the
hope future readers will have a little easier time understanding what it is
supposed to do.

The warnings showed up in
[https://gitlab.dune-project.org/core/dune-common/-/jobs/139437\#L665]
(debian:10 clang-7-libcpp-17):

    [ 60%] Building CXX object dune/common/test/CMakeFiles/fvectorconversion1d.dir/fvectorconversion1d.cc.o
    /builds/core/dune-common/dune/common/test/fvectorconversion1d.cc:86:16: warning: unused variable 'mfv' [-Wunused-variable]
          MiddleFV mfv;
                   ^
    /builds/core/dune-common/dune/common/test/fvectorconversion1d.cc:107:16: warning: unused variable 'mfv' [-Wunused-variable]
          MiddleFV mfv;
                   ^
    2 warnings generated.

See also: [!735], [!562]

See merge request [!773]

  [https://gitlab.dune-project.org/core/dune-common/-/jobs/139437\#L665]: https://gitlab.dune-project.org/core/dune-common/-/jobs/139437#L665
  [!735]: gitlab.dune-project.org/NoneNone/merge_requests/735
  [!562]: gitlab.dune-project.org/NoneNone/merge_requests/562
  [!773]: gitlab.dune-project.org/core/dune-common/merge_requests/773
parents a7b1615b 1802c531
Branches
Tags
1 merge request!773Fix warnings, add comments in fvectorconversion1d.cc test
Pipeline #24637 passed
......@@ -13,6 +13,14 @@
#include <dune/common/exceptions.hh>
#include <dune/common/unused.hh>
//! @file
/**
* This test tests for a regression, where `std::is_assignable` would return
* `true` for certain assignments, but it was not actually possible to
* instantiate those assignments. In the fix `std::is_assignable` was fixed
* to report false, and that is what is checked now.
*/
template<class Component, std::size_t Dim >
class MyVector;
......@@ -72,8 +80,8 @@ int main()
mfv = mv;
}
// The following will trigger a problem in the DenseVector
// operator=() which can be cured by first checking whether the
// The following would trigger a problem in the DenseVector
// operator=() which was cured by first checking whether the
// value_types are assignable.
{
using InnerFV = Dune::FieldVector<double, 2>;
......@@ -83,7 +91,7 @@ int main()
using MiddleMV = MyVector<InnerFV, 1>;
using OuterMV = MyVector<MiddleMV, 1>;
MiddleFV mfv;
// MiddleFV mfv;
OuterMV mv;
OuterFV fv;
......@@ -91,9 +99,10 @@ int main()
"DenseVectors should be convertible.");
fv = mv;
// before the fix, `is_assignable` returned `true`,
static_assert(!std::is_assignable<MiddleFV&, OuterMV>::value,
"Inconsistent assignability detected.");
// mfv = mv; // <- this would not compile dispite the assignability check.
// mfv = mv; // <- but this assignment failed instantiation
}
{
......@@ -104,7 +113,7 @@ int main()
using MiddleMV = MyVector<InnerFV, 1>;
using OuterMV = MyVector<MiddleMV, 1>;
MiddleFV mfv;
// MiddleFV mfv;
OuterMV mv;
OuterFV fv;
......@@ -112,9 +121,10 @@ int main()
"DenseVectors should be assignable.");
fv = mv;
// before the fix, `is_assignable` returned `true`,
static_assert(!std::is_assignable<MiddleFV&, OuterMV>::value,
"Inconsistent assignability detected.");
// mfv = mv; // <- this would not compile dispite the assignability check.
// mfv = mv; // <- but this assignment failed instantiation
}
return 0;
} catch (Dune::Exception& e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment