Commit 7518d067 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Try to fix uninitialized anonymous variable warning

The code from the previous commit was causing one of the dashboards,
which is using gcc-7, to produce the following warning:

In file included from ../testing/UnitTestVariant.cxx:11:0:
../Variant.h: In function 'void {anonymous}::TestCopyDestroy()':
../Variant.h:269:5: warning: '<anonymous>' may be used uninitialized in this function [-Wmaybe-uninitialized]
     this->Storage = std::move(rhs.Storage);
     ^~~~

At best, this warning is not helpful as it does not seem to point to
anything that could be used uninitialized. At worst, it might be a
compiler bug. A Google search finds a few similar bugs although none I
can assert with any confidence of this issue. However, many reported
bugs and issues point to the use of anonymous namespaces. So, I'm going
to attempt to fix the problem by removing anonymous namespaces.
Hopefully it will fix the warning or at least point me to something
concrete that I can fix.
parent 5b18ffd7
......@@ -15,7 +15,7 @@
#include <memory>
#include <vector>
namespace
namespace test_variant
{
template <vtkm::IdComponent Index>
......@@ -141,26 +141,26 @@ void TestCastAndCall()
VTKM_TEST_ASSERT(test_equal(result, TestValue(3, vtkm::FloatDefault{})));
}
struct CountConstructDestruct
{
vtkm::Id* Count;
CountConstructDestruct(vtkm::Id* count)
: Count(count)
{
++(*this->Count);
}
CountConstructDestruct(const CountConstructDestruct& src)
: Count(src.Count)
{
++(*this->Count);
}
~CountConstructDestruct() { --(*this->Count); }
};
void TestCopyDestroy()
{
std::cout << "Test copy destroy" << std::endl;
struct CountConstructDestruct
{
vtkm::Id* Count;
CountConstructDestruct(vtkm::Id* count)
: Count(count)
{
++(*this->Count);
}
CountConstructDestruct(const CountConstructDestruct& src)
: Count(src.Count)
{
++(*this->Count);
}
~CountConstructDestruct() { --(*this->Count); }
};
using VariantType = vtkm::internal::Variant<TypePlaceholder<0>,
TypePlaceholder<1>,
CountConstructDestruct,
......@@ -253,9 +253,9 @@ void RunTest()
TestEmplace();
}
} // anonymous namespace
} // namespace test_variant
int UnitTestVariant(int argc, char* argv[])
{
return vtkm::testing::Testing::Run(RunTest, argc, argv);
return vtkm::testing::Testing::Run(test_variant::RunTest, argc, argv);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment