changeset 3585:113a9643e8bb

Suppressed a few warnings when building with emscripten (clang) + numeric truncation warnings
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 02 Dec 2019 10:59:40 +0100
parents 75268c1ea309
children 732922e48937
files Core/Images/ImageProcessing.cpp Core/JobsEngine/JobInfo.cpp Core/SQLite/FunctionContext.cpp Core/SQLite/Statement.cpp
diffstat 4 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Sun Dec 01 11:12:48 2019 +0100
+++ b/Core/Images/ImageProcessing.cpp	Mon Dec 02 10:59:40 2019 +0100
@@ -39,6 +39,17 @@
 #include "PixelTraits.h"
 #include "../OrthancException.h"
 
+#ifdef __EMSCRIPTEN__
+/* 
+Avoid this error:
+-----------------
+.../boost/math/special_functions/round.hpp:118:12: warning: implicit conversion from 'std::__2::numeric_limits<long long>::type' (aka 'long long') to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
+.../mnt/c/osi/dev/orthanc/Core/Images/ImageProcessing.cpp:333:28: note: in instantiation of function template specialization 'boost::math::llround<float>' requested here
+.../mnt/c/osi/dev/orthanc/Core/Images/ImageProcessing.cpp:1006:9: note: in instantiation of function template specialization 'Orthanc::MultiplyConstantInternal<unsigned char, true>' requested here
+*/
+#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
+#endif 
+
 #include <boost/math/special_functions/round.hpp>
 
 #include <cassert>
@@ -1874,7 +1885,7 @@
       
     for (unsigned int x = 0; x < targetWidth; x++)
     {
-      int sourceX = std::floor((static_cast<float>(x) + 0.5f) * scaleX);
+      int sourceX = static_cast<int>(std::floor((static_cast<float>(x) + 0.5f) * scaleX));
       if (sourceX < 0)
       {
         sourceX = 0;  // Should never happen
@@ -1891,7 +1902,7 @@
       
     for (unsigned int y = 0; y < targetHeight; y++)
     {
-      int sourceY = std::floor((static_cast<float>(y) + 0.5f) * scaleY);
+      int sourceY = static_cast<int>(std::floor((static_cast<float>(y) + 0.5f) * scaleY));
       if (sourceY < 0)
       {
         sourceY = 0;  // Should never happen
@@ -2173,7 +2184,8 @@
         }
 
         // Deal with the right border
-        for (unsigned int x = horizontalAnchor + width - horizontal.size() + 1; x < width; x++)
+        for (unsigned int x = static_cast<unsigned int>(
+          horizontalAnchor + width - horizontal.size() + 1); x < width; x++)
         {
           for (unsigned int c = 0; c < ChannelsCount; c++, p++)
           {
@@ -2205,7 +2217,7 @@
         }
         else
         {
-          rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(y + k - verticalAnchor));
+          rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(static_cast<unsigned int>(y + k - verticalAnchor)));
         }
       }
 
--- a/Core/JobsEngine/JobInfo.cpp	Sun Dec 01 11:12:48 2019 +0100
+++ b/Core/JobsEngine/JobInfo.cpp	Mon Dec 02 10:59:40 2019 +0100
@@ -32,6 +32,22 @@
 
 
 #include "../PrecompiledHeaders.h"
+
+#ifdef __EMSCRIPTEN__
+/* 
+Avoid this error:
+
+.../boost/math/special_functions/round.hpp:118:12: warning: implicit conversion from 'std::__2::numeric_limits<long long>::type' (aka 'long long') to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
+.../boost/math/special_functions/round.hpp:125:11: note: in instantiation of function template specialization 'boost::math::llround<float, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >' requested here
+.../orthanc/Core/JobsEngine/JobInfo.cpp:69:44: note: in instantiation of function template specialization 'boost::math::llround<float>' requested here
+
+.../boost/math/special_functions/round.hpp:86:12: warning: implicit conversion from 'std::__2::numeric_limits<int>::type' (aka 'int') to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-int-float-conversion]
+.../boost/math/special_functions/round.hpp:93:11: note: in instantiation of function template specialization 'boost::math::iround<float, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >' requested here
+.../orthanc/Core/JobsEngine/JobInfo.cpp:133:39: note: in instantiation of function template specialization 'boost::math::iround<float>' requested here
+*/
+#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
+#endif 
+
 #include "JobInfo.h"
 
 #include "../OrthancException.h"
--- a/Core/SQLite/FunctionContext.cpp	Sun Dec 01 11:12:48 2019 +0100
+++ b/Core/SQLite/FunctionContext.cpp	Mon Dec 02 10:59:40 2019 +0100
@@ -121,7 +121,7 @@
 
     void FunctionContext::SetStringResult(const std::string& str)
     {
-      sqlite3_result_text(context_, str.data(), str.size(), SQLITE_TRANSIENT);
+      sqlite3_result_text(context_, str.data(), static_cast<int>(str.size()), SQLITE_TRANSIENT);
     }
   }
 }
--- a/Core/SQLite/Statement.cpp	Sun Dec 01 11:12:48 2019 +0100
+++ b/Core/SQLite/Statement.cpp	Mon Dec 02 10:59:40 2019 +0100
@@ -218,7 +218,7 @@
       CheckOk(sqlite3_bind_text(GetStatement(),
                                 col + 1,
                                 val.data(),
-                                val.size(),
+                                static_cast<int>(val.size()),
                                 SQLITE_TRANSIENT),
               ErrorCode_BadParameterType);
     }