1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

imgproc: fix -Wstringop-overflow false-positive in minEnclosingConvexPolygon

This commit addresses a compiler warning encountered when building with GCC 13 and C++20.
The compiler triggers a false-positive -Wstringop-overflow warning in `findKSides`.

By adding `sides.reserve(k)`, we explicitly inform the compiler about the required
memory allocation, which suppresses the warning and provides a minor optimization
by avoiding potential reallocations.
This commit is contained in:
Kumataro
2026-02-22 07:58:04 +09:00
parent 95be2f2af8
commit 5ef5aab435
@@ -913,6 +913,7 @@ std::vector<Side> Chains::reconstructHSidedChain(int h, int i, int j)
std::vector<Side> Chains::findKSides(int k, int i, int j)
{
std::vector<Side> sides;
sides.reserve(k); // Optimization and avoiding GCC's false positive warning (-Wstringop-overflow)
sides.push_back({i, true});
sides.push_back({j, true});