Commit b44e784a authored by Lukas-Buricin's avatar Lukas-Buricin Committed by Davis E. King

Fixed VS 2017 level-3 warnings (#1193)

parent 973f4536
...@@ -168,7 +168,9 @@ namespace dlib ...@@ -168,7 +168,9 @@ namespace dlib
DLIB_CASSERT(x.size() > 0); DLIB_CASSERT(x.size() > 0);
for (size_t i = 0; i < x.size(); ++i) for (size_t i = 0; i < x.size(); ++i)
DLIB_CASSERT(anchor.size() == x[i].size()); DLIB_CASSERT(anchor.size() == x[i].size());
DLIB_CASSERT(anchor.size()+1 <= x.size() && x.size() <= (anchor.size()+1)*(anchor.size()+2)/2);
long x_size = static_cast<long>(x.size());
DLIB_CASSERT(anchor.size()+1 <= x_size && x_size <= (anchor.size()+1)*(anchor.size()+2)/2);
matrix<double> X(anchor.size(), x.size()); matrix<double> X(anchor.size(), x.size());
...@@ -214,7 +216,7 @@ namespace dlib ...@@ -214,7 +216,7 @@ namespace dlib
// their best observed value and use the QP to optimize the real variables. So the // their best observed value and use the QP to optimize the real variables. So the
// number of dimensions, as far as the QP is concerned, is the number of non-integer // number of dimensions, as far as the QP is concerned, is the number of non-integer
// variables. // variables.
long dims = 0; size_t dims = 0;
for (auto is_int : is_integer_variable) for (auto is_int : is_integer_variable)
{ {
if (!is_int) if (!is_int)
...@@ -225,7 +227,7 @@ namespace dlib ...@@ -225,7 +227,7 @@ namespace dlib
// Use enough points to fill out a quadratic model or the max available if we don't // Use enough points to fill out a quadratic model or the max available if we don't
// have quite enough. // have quite enough.
const long N = std::min((long)samples.size(), (dims+1)*(dims+2)/2); const long N = std::min(samples.size(), (dims+1)*(dims+2)/2);
// first find the best sample; // first find the best sample;
...@@ -376,7 +378,7 @@ namespace dlib ...@@ -376,7 +378,7 @@ namespace dlib
lower(std::move(bound1)), upper(std::move(bound2)) lower(std::move(bound1)), upper(std::move(bound2))
{ {
DLIB_CASSERT(lower.size() == upper.size()); DLIB_CASSERT(lower.size() == upper.size());
for (size_t i = 0; i < lower.size(); ++i) for (long i = 0; i < lower.size(); ++i)
{ {
if (upper(i) < lower(i)) if (upper(i) < lower(i))
std::swap(lower(i), upper(i)); std::swap(lower(i), upper(i));
......
...@@ -33,6 +33,12 @@ ...@@ -33,6 +33,12 @@
// warning off and then turning it back on at the end of the file. // warning off and then turning it back on at the end of the file.
#pragma warning(disable : 4355) #pragma warning(disable : 4355)
// "warning C4723: potential divide by 0" - This warning is triggered in
// matrix(const std::initializer_list<T>& l) where the compiler can see that
// matrix<> was templated in a way making NR ending up 0, but division by 0 at runtime
// is not possible because the division operation is inside "if (NR!=0)" block.
#pragma warning(disable : 4723)
#endif #endif
namespace dlib namespace dlib
...@@ -2147,8 +2153,9 @@ namespace dlib ...@@ -2147,8 +2153,9 @@ namespace dlib
} }
#ifdef _MSC_VER #ifdef _MSC_VER
// put that warning back to its default setting // put warnings back to their default settings
#pragma warning(default : 4355) #pragma warning(default : 4355)
#pragma warning(default : 4723)
#endif #endif
#endif // DLIB_MATRIx_ #endif // DLIB_MATRIx_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment