From c25abd25f8d4c866bfa1ba2fbf1e06bc7b8beeeb Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org> Date: Fri, 13 Jun 2014 17:47:14 +0300 Subject: [PATCH] ENH: explicit cast to avoid narrow conversion in internal libsiftfast Following recent commits on the ITK side which use clang-modernize to insert missing override keyword, cf: https://github.com/InsightSoftwareConsortium/ITK/commit/10757725be9cbe68ab2903c9cd4b76b738070e63 I had to compile OTB trunk using clang and c++11 flags: mkdir OTB-newclang cd OTB-newclang/ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS="-std=c++11 -stdlib=libstdc++" ccmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON ../../../src/OTB Internal libsiftfast does not compile as clang report error "error: argument evaluates to XXX which cannot be narrowed to type YYY" I added explicit cast to int in that cases. --- Utilities/otbsiftfast/libsiftfast.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/otbsiftfast/libsiftfast.cpp b/Utilities/otbsiftfast/libsiftfast.cpp index 04d563c855..1c32b24fef 100644 --- a/Utilities/otbsiftfast/libsiftfast.cpp +++ b/Utilities/otbsiftfast/libsiftfast.cpp @@ -594,7 +594,7 @@ void ConvBuffer(float* buf, float* kernel, int bufsize, int ksize) typedef vector<float*> LISTBUF; static LISTBUF s_listconvbuf; //TODO, make 16 byte aligned static int s_convbufsize = 0; // the size of all the buffers in s_listconvbuf -static int SIFT_ALIGNED16(s_convmask[4]) = {0xffffffff,0xffffffff,0xffffffff,0}; +static int SIFT_ALIGNED16(s_convmask[4]) = {static_cast<int>(0xffffffff),static_cast<int>(0xffffffff),static_cast<int>(0xffffffff),0}; struct myaccum { float SIFT_ALIGNED16(faccum[2][4]); }; @@ -1750,7 +1750,7 @@ vec_float4 C-style expressions DEF_CONST(CF4_0, 0.0f) DEF_CONST(CF4_2, 2.0f) -DEI_CONST(CI4_SIGN, 0x80000000u) +DEI_CONST(CI4_SIGN, static_cast<int>(0x80000000u)) DEF_CONST(CF4__1, -1.0f) DEF_CONST(CF4_1, 1.0f) DEF_CONST(CF4_SMALL, 1.0E-35f) -- GitLab