-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Types in core/types.hpp should be trivially copyable. #20718
Copy link
Copy link
Closed
Milestone
Description
System information (version)
- OpenCV => 4.5.3
Detailed description
Take, for example, cv::Point_.
There are user provided copy and move constructors, copy assignment and move assignment operators defined:
opencv/modules/core/include/opencv2/core/types.hpp
Lines 165 to 166 in 3c89a28
| Point_(const Point_& pt); | |
| Point_(Point_&& pt) CV_NOEXCEPT; |
opencv/modules/core/include/opencv2/core/types.hpp
Lines 170 to 171 in 3c89a28
| Point_& operator = (const Point_& pt); | |
| Point_& operator = (Point_&& pt) CV_NOEXCEPT; |
Because of that, the type is not trivially copyable. For example, that means you can't use std::memcopy or std::atomic with the type.
The fix for that would be to remove those constructors and operators altogether, since the compiler would generate the identical implicitly-defined ones.
Steps to reproduce
#include <opencv2/core/types.hpp>
#include <type_traits>
#include <iostream>
int main() {
std::cout << std::is_trivially_copyable_v<cv::Point>; // => 0
}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 solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Reactions are currently unavailable