From 5ef5aab4354ca353c3a9e2ebe75a62b7dc3b1e29 Mon Sep 17 00:00:00 2001 From: Kumataro Date: Sun, 22 Feb 2026 07:58:04 +0900 Subject: [PATCH] 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. --- modules/imgproc/src/min_enclosing_convex_polygon.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/imgproc/src/min_enclosing_convex_polygon.cpp b/modules/imgproc/src/min_enclosing_convex_polygon.cpp index c97ada4abc..2f12b0e474 100644 --- a/modules/imgproc/src/min_enclosing_convex_polygon.cpp +++ b/modules/imgproc/src/min_enclosing_convex_polygon.cpp @@ -913,6 +913,7 @@ std::vector Chains::reconstructHSidedChain(int h, int i, int j) std::vector Chains::findKSides(int k, int i, int j) { std::vector sides; + sides.reserve(k); // Optimization and avoiding GCC's false positive warning (-Wstringop-overflow) sides.push_back({i, true}); sides.push_back({j, true});