Skip to content

Defaulted operator= for cv::Vec<T, N> should be made explicit #14933

@StefanBruens

Description

@StefanBruens

GCC9 issues many warnings like:

./opencv/modules/imgproc/src/templmatch.cpp: In function ‘bool cv::matchTemplate_CCOEFF(cv::InputArray, cv::InputArray, cv::OutputArray)’:
./opencv/modules/imgproc/src/templmatch.cpp:464:38: warning: implicitly-declared ‘constexpr cv::Vec<float, 4>& cv::Vec<float, 4>::operator=(const cv::Vec<float, 4>&)’ is deprecated [-Wdeprecated-copy]
  464 |         templ_sum = (Vec4f)mean(templ);
      |                                      ^
In file included from ./opencv/modules/core/include/opencv2/core.hpp:57,
                 from ./opencv/modules/imgproc/include/opencv2/imgproc.hpp:46,
                 from /./opencv/build/modules/imgproc/precomp.hpp:46:
./opencv/modules/core/include/opencv2/core/matx.hpp:1030:1: note: because ‘cv::Vec<float, 4>’ has user-provided ‘cv::Vec<_Tp, cn>::Vec(const cv::Vec<_Tp, cn>&) [with _Tp = float; int cn = 4]’
 1030 | Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
      | ^~~~~~~~~~~~

openCV should follow the "rule of five", see e.g.
http://www.stroustrup.com/C++11FAQ.html#default

It is sufficient to explicitly tell the compiler to default the assignment operator, i.e.

    constexpr Vec<_Tp, cn>& operator=(const Vec<_Tp, cn>& rhs) = default;
System information (version)
  • OpenCV => 3.4.6, 4.1.0
  • Operating System / Platform => Linux 64 Bit, openSUSE Tumleweed
  • Compiler => GCC 9 (gcc (SUSE Linux) 9.1.1 20190611 [gcc-9-branch revision 272147])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions