From 173a1cf711aca87901f0817a9113a87974af076d Mon Sep 17 00:00:00 2001 From: Kumataro Date: Sun, 8 Nov 2026 10:48:56 +0900 Subject: [PATCH] dnn, features2d, imgproc: fix build warnings with GCC 15 / C++20 - dnn: suppress false-positive std::vector::insert warning in ONNX GRU parser - features2d: simplify indexChange initialization in BRISK kernel generation - imgproc: fix implicit conversion warnings with INTER_TAB_SIZE in SIMD remap and warp tests --- modules/dnn/src/onnx/onnx_importer.cpp | 2 ++ modules/features2d/src/brisk.cpp | 8 ++++---- modules/imgproc/src/imgwarp.simd.hpp | 6 +++--- modules/imgproc/test/ocl/test_warp.cpp | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/dnn/src/onnx/onnx_importer.cpp b/modules/dnn/src/onnx/onnx_importer.cpp index aee0fb8469..b4dc3e1573 100644 --- a/modules/dnn/src/onnx/onnx_importer.cpp +++ b/modules/dnn/src/onnx/onnx_importer.cpp @@ -1757,6 +1757,8 @@ void ONNXImporter::parseGRU(LayerParams& layerParams, const opencv_onnx::NodePro MatShape gruShape = outShapes[node_proto.output(0)]; + CV_CheckFalse(gruShape.empty(), "ERROR outShapes[node_proto.output(0)] is empty"); + // Add fake 1 as it is done in ONNX gruShape.insert(gruShape.begin() + 1, 1); diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 7eaf5880cf..9b3fb81477 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -501,15 +501,15 @@ BRISK_Impl::generateKernel(const std::vector &radiusList, noLongPairs_ = 0; // fill indexChange with 0..n if empty - unsigned int indSize = (unsigned int)indexChange.size(); - if (indSize == 0) + if (indexChange.empty()) { indexChange.resize(points_ * (points_ - 1) / 2); - indSize = (unsigned int)indexChange.size(); - for (unsigned int i = 0; i < indSize; i++) + for (unsigned int i = 0; i < (unsigned int)indexChange.size(); i++) indexChange[i] = i; } + unsigned int indSize = (unsigned int)indexChange.size(); + const float dMin_sq = dMin_ * dMin_; const float dMax_sq = dMax_ * dMax_; for (unsigned int i = 1; i < points_; i++) diff --git a/modules/imgproc/src/imgwarp.simd.hpp b/modules/imgproc/src/imgwarp.simd.hpp index f7eb4397b7..b11eb73501 100644 --- a/modules/imgproc/src/imgwarp.simd.hpp +++ b/modules/imgproc/src/imgwarp.simd.hpp @@ -128,7 +128,7 @@ static int remapBilinearC1_run(const T* S0, size_t sstep, T* D, const int vlanes = VTraits::vlanes(); const int dx0 = dx; const v_float32 vone = vx_setall_f32(1.f); - const v_float32 vscale = vx_setall_f32(1.f / INTER_TAB_SIZE); + const v_float32 vscale = vx_setall_f32(1.f / static_cast(INTER_TAB_SIZE)); const v_int32 vmask = vx_setall_s32(INTER_TAB_SIZE - 1); int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ofs[VTraits::max_nlanes]; for( ; dx <= X1 - vlanes; dx += vlanes ) @@ -168,7 +168,7 @@ static int remapBilinearF32_run(const float* S0, size_t sstep, float* D, const int dx0 = dx; const float* S1 = S0 + sstep; const v_float32 vone = vx_setall_f32(1.f); - const v_float32 vscale = vx_setall_f32(1.f / INTER_TAB_SIZE); + const v_float32 vscale = vx_setall_f32(1.f / static_cast(INTER_TAB_SIZE)); const v_int32 vmask = vx_setall_s32(INTER_TAB_SIZE - 1); int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ofs[VTraits::max_nlanes]; for( ; dx <= X1 - vlanes; dx += vlanes ) @@ -239,7 +239,7 @@ static int remapBicubicC1_run(const T* S0, size_t sstep, T* D, const short* XY, { const int vlanes = VTraits::vlanes(); const int dx0 = dx; - const v_float32 vscale = vx_setall_f32(1.f / INTER_TAB_SIZE); + const v_float32 vscale = vx_setall_f32(1.f / static_cast(INTER_TAB_SIZE)); const v_int32 vmask = vx_setall_s32(INTER_TAB_SIZE - 1); int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ofs[VTraits::max_nlanes]; float CV_DECL_ALIGNED(CV_SIMD_WIDTH) buf[VTraits::max_nlanes]; diff --git a/modules/imgproc/test/ocl/test_warp.cpp b/modules/imgproc/test/ocl/test_warp.cpp index eac9548ea0..2ccfb7f124 100644 --- a/modules/imgproc/test/ocl/test_warp.cpp +++ b/modules/imgproc/test/ocl/test_warp.cpp @@ -588,8 +588,8 @@ private: { const float fx = mapx.at(y, x); const float fy = mapy.at(y, x); - const int scaledX = static_cast(std::floor(fx * INTER_TAB_SIZE + 0.5f)); - const int scaledY = static_cast(std::floor(fy * INTER_TAB_SIZE + 0.5f)); + const int scaledX = static_cast(std::floor(fx * static_cast(INTER_TAB_SIZE) + 0.5f)); + const int scaledY = static_cast(std::floor(fy * static_cast(INTER_TAB_SIZE) + 0.5f)); const int sx = scaledX >> INTER_BITS; const int sy = scaledY >> INTER_BITS; const T wx = static_cast(scaledX & (INTER_TAB_SIZE - 1)) /