From 65f87b114b545b73a43232c15e0bd345406c4896 Mon Sep 17 00:00:00 2001
From: pemmanuelviel
Date: Sat, 4 Jul 2020 19:15:44 +0200
Subject: [PATCH] Merge pull request #17722 from
pemmanuelviel:pev--replace-asserts
* Clean: replace C style asserts by CV_Assert and CV_DbgAssert
* Try fixing warning on Windows compilation
* Another way trying to fix warnings on Win
* Fixing warnings with some compilers:
Some compilers warn on systematic exit preventing to execute the code that follows.
This is why assert(0) that exits only in debug was working, but not CV_Assert or CV_Error
that exit both in release and debug, even if with different behavior.
In addition, other compilers complain when return 0 is removed from getKey(),
even if before we have a statement leading to systematic exit.
* Disable "unreachable code" warnings for Win compilers so we can use proper CV_Error
---
.../include/opencv2/flann/autotuned_index.h | 2 +-
.../include/opencv2/flann/flann_base.hpp | 1 -
.../flann/hierarchical_clustering_index.h | 9 ++++-----
.../include/opencv2/flann/index_testing.h | 1 -
.../include/opencv2/flann/kdtree_index.h | 5 ++---
.../opencv2/flann/kdtree_single_index.h | 11 +++++-----
.../include/opencv2/flann/kmeans_index.h | 9 ++++-----
.../flann/include/opencv2/flann/lsh_index.h | 20 +++++++++++++------
.../flann/include/opencv2/flann/lsh_table.h | 16 +++++++++++----
.../flann/include/opencv2/flann/nn_index.h | 10 +++++-----
.../include/opencv2/flann/simplex_downhill.h | 2 +-
11 files changed, 48 insertions(+), 38 deletions(-)
diff --git a/modules/flann/include/opencv2/flann/autotuned_index.h b/modules/flann/include/opencv2/flann/autotuned_index.h
index eb4554f077..54a60a73d6 100644
--- a/modules/flann/include/opencv2/flann/autotuned_index.h
+++ b/modules/flann/include/opencv2/flann/autotuned_index.h
@@ -497,7 +497,7 @@ private:
const int nn = 1;
const size_t SAMPLE_COUNT = 1000;
- assert(bestIndex_ != NULL); // must have a valid index
+ CV_Assert(bestIndex_ != NULL && "Requires a valid index"); // must have a valid index
float speedup = 0;
diff --git a/modules/flann/include/opencv2/flann/flann_base.hpp b/modules/flann/include/opencv2/flann/flann_base.hpp
index 83606d232f..641fdb01e2 100644
--- a/modules/flann/include/opencv2/flann/flann_base.hpp
+++ b/modules/flann/include/opencv2/flann/flann_base.hpp
@@ -34,7 +34,6 @@
//! @cond IGNORED
#include
-#include
#include
#include "general.h"
diff --git a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h
index d830bc6a00..a52166d3c4 100644
--- a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h
+++ b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h
@@ -35,7 +35,6 @@
#include
#include