Skip to content

TensorVolumePatchOp: Suppress Wmaybe-uninitialized caused by unreachable code

Reference issue

What does this implement/fix?

Suppresses compiler warning caused by unreachable switch case statement. Alternatively, we could define EIGEN_UNREACHABLE. I know @cantonios loves macros!

We could plagiarize cppref as a starting point: https://en.cppreference.com/w/cpp/utility/unreachable

[[noreturn]] inline void unreachable()
{
    // Uses compiler specific extensions if possible.
    // Even if no extension is used, undefined behavior is still raised by
    // an empty function body and the noreturn attribute.
#if defined(_MSC_VER) && !defined(__clang__) // MSVC
    __assume(false);
#else // GCC, Clang
    __builtin_unreachable();
#endif
}

Here's the annoying warning:

[1/26] Building CXX object unsupported/test/CMakeFiles/cxx11_tensor_thread_pool_4.dir/cxx11_tensor_thread_pool.cpp.o
In file included from ../unsupported/test/../../unsupported/Eigen/CXX11/Tensor:104,
                 from ../unsupported/test/cxx11_tensor_thread_pool.cpp:14:
../unsupported/test/../../unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h: In static member function 'static void Eigen::internal::TensorExecutor<Expression, Eigen::ThreadPoolDevice, Vectorizable, Tiling>::run(const Expression&, const Eigen::ThreadPoolDevice&) [with Expression = const Eigen::TensorAssignOp<Eigen::Tensor<float, 6>, const Eigen::TensorVolumePatchOp<-1, -1, -1, const Eigen::Tensor<float, 5> > >; bool Vectorizable = true; Eigen::internal::TiledEvaluation Tiling = Eigen::internal::Off]':
../unsupported/test/../../unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h:283:18: warning: '*((void*)(& evaluator)+64).Eigen::TensorEvaluator<const Eigen::TensorVolumePatchOp<-1, -1, -1, const Eigen::Tensor<float, 5> >, Eigen::ThreadPoolDevice>::m_outputRows' may be used uninitialized in this function [-Wmaybe-uninitialized]
  283 |     eigen_assert(m_outputRows > 0);

Additional information

Edited by Charles Schlosser

Merge request reports

Loading