2 years ago
#52136
iliis
clang-tidy fails with OpenCV code that compiles fine
clang-tidy
fails on this simple program:
#include <opencv2/core.hpp>
int main()
{
cv::Mat m;
m.at<const cv::Vec2i>(12, 34);
return 0;
}
when run with
clang-tidy-13 test.cpp -- -I/usr/include/opencv4 -l/usr/lib/x86_64-linux-gnu/libopencv_core.so
I get the following errors:
3 errors generated.
Error while processing /tmp/bla/test.cpp.
/usr/include/opencv4/opencv2/core/mat.inl.hpp:1144:49: error: no member named 'channels' in 'cv::DataType<const cv::Vec<int, 2>>' [clang-diagnostic-error]
CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()));
^
/tmp/bla/test.cpp:6:7: note: in instantiation of function template specialization 'cv::Mat::at<const cv::Vec<int, 2>>' requested here
m.at<const cv::Vec2i>(12, 34);
^
/usr/include/opencv4/opencv2/core/mat.inl.hpp:1145:50: error: incomplete definition of type 'cv::traits::Depth<const cv::Vec<int, 2>>' [clang-diagnostic-error]
CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1());
^
/usr/include/opencv4/opencv2/core/cvdef.h:448:58: note: expanded from macro 'CV_ELEM_SIZE1'
#define CV_ELEM_SIZE1(type) ((0x28442211 >> CV_MAT_DEPTH(type)*4) & 15)
^~~~
/usr/include/opencv4/opencv2/core/hal/interface.h:83:35: note: expanded from macro 'CV_MAT_DEPTH'
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
^~~~~
/usr/include/opencv4/opencv2/core/base.hpp:372:40: note: expanded from macro 'CV_DbgAssert'
# define CV_DbgAssert(expr) CV_Assert(expr)
^~~~
/usr/include/opencv4/opencv2/core/base.hpp:306:38: note: expanded from macro 'CV_Assert'
#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)
^~~~
/tmp/bla/test.cpp:6:7: note: in instantiation of function template specialization 'cv::Mat::at<const cv::Vec<int, 2>>' requested here
m.at<const cv::Vec2i>(12, 34);
^
/usr/include/opencv4/opencv2/core/traits.hpp:382:31: error: no member named 'depth' in 'cv::DataType<const cv::Vec<int, 2>>' [clang-diagnostic-error]
{ enum { value = DataType<T>::depth }; };
~~~~~~~~~~~~~^
/usr/include/opencv4/opencv2/core/mat.inl.hpp:1145:40: note: in instantiation of template class 'cv::traits::Depth<const cv::Vec<int, 2>>' requested here
CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1());
^
/tmp/bla/test.cpp:6:7: note: in instantiation of function template specialization 'cv::Mat::at<const cv::Vec<int, 2>>' requested here
m.at<const cv::Vec2i>(12, 34);
^
Found compiler error(s).
However, this file compiles and runs fine with both GCC and LLVM:
g++ -I/usr/include/opencv4 test.cpp /usr/lib/x86_64-linux-gnu/libopencv_core.so
clang++ -I/usr/include/opencv4 test.cpp /usr/lib/x86_64-linux-gnu/libopencv_core.so
I tried with GCC 10.3.0, LLVM 10.0.0 and 13.0.1 on Ubuntu 20.04 with OpenCV version 4.2.0.
c++
opencv
clang
ubuntu-20.04
clang-tidy
0 Answers
Your Answer