Skip to content

Instantly share code, notes, and snippets.

@tomoaki0705
Last active July 6, 2022 12:53
Show Gist options
  • Save tomoaki0705/cfed9b90a0807e02eeebf90cc395a2bb to your computer and use it in GitHub Desktop.
Save tomoaki0705/cfed9b90a0807e02eeebf90cc395a2bb to your computer and use it in GitHub Desktop.
So many warnings on GCC11
System information (version)
  • OpenCV => recent 3.4 branch ( 3891b72f33572a55a038b6859909f65218533b9a )
  • Operating System / Platform => Ubuntu 22.04 Arm 32bit (ODROID-XU4)
  • Compiler => GCC 11.2
Detailed description

There are somany warnings such as following

In file included from /usr/include/c++/11/vector:72,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /opencv-fork/modules/core/include/opencv2/core/base.hpp:55,
                 from /opencv-fork/modules/core/include/opencv2/core.hpp:53,
                 from /opencv-fork/modules/core/include/opencv2/core/utility.hpp:56,
                 from /opencv-fork/modules/calib3d/src/precomp.hpp:45,
                 from /opencv-fork/modules/calib3d/src/five-point.cpp:32:
/usr/include/c++/11/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const double&}; _Tp = double; _Alloc = std::allocator<double>]':
/usr/include/c++/11/bits/vector.tcc:426:7: note: parameter passing for argument of type 'std::vector<double, std::allocator<double> >::iterator' changed in GCC 7.1
  426 |       vector<_Tp, _Alloc>::
      |       ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {double}; _Tp = double; _Alloc = std::allocator<double>]':
/usr/include/c++/11/bits/vector.tcc:426:7: note: parameter passing for argument of type 'std::vector<double, std::allocator<double> >::iterator' changed in GCC 7.1
/usr/include/c++/11/bits/vector.tcc: In member function 'virtual int cv::EMEstimatorCallback::runKernel(cv::InputArray, cv::InputArray, cv::OutputArray) const':
/usr/include/c++/11/bits/vector.tcc:121:28: note: parameter passing for argument of type '__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >' changed in GCC 7.1
  121 |           _M_realloc_insert(end(), std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:121:28: note: parameter passing for argument of type '__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >' changed in GCC 7.1
  121 |           _M_realloc_insert(end(), std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are SOOOO many lines such as this line

$ grep -c "changed in GCC" arm-build.log
708

After googling a while, I came up to conclusion that this is a possible ABI mismatch when running on a different machine from compiled one.

This is an ABI change. If the option -Wpsabi is enabled (on by default) the compiler will emit a diagnostic note for code that might be affected.

More to write here, but as a summary, this begins with a GCC bug, and the warning is raised. The only workaround is to use -Wno-psabi.

I tried to minimize the modification by using pragma pop but this -Wno-psabi was not available with combination with pragma. Thus, I have to insert ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-psabi) to every module that triggers this warning.

I'll send a patch later, but I hope my solution is acceptable.

Steps to reproduce

Build recent OpenCV on GCC 7 or later on Arm 32bit platform

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment