[Beignet] [PATCH 2/2] fix gcc warning "comparison between signed and unsigned expressions"

xionghu.luo at intel.com xionghu.luo at intel.com
Wed May 6 18:46:53 PDT 2015


From: Luo Xionghu <xionghu.luo at intel.com>

this warning appeared in gcc 4.9.1.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 utests/compiler_clz.cpp      | 16 ++++++++--------
 utests/compiler_popcount.cpp |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/utests/compiler_clz.cpp b/utests/compiler_clz.cpp
index 9116608..53a418f 100644
--- a/utests/compiler_clz.cpp
+++ b/utests/compiler_clz.cpp
@@ -81,13 +81,13 @@ void test(const char *kernel_name, int s_type)
   {
     for (uint32_t i = 0; i < n; ++i) {
       if(sizeof(U) == 1 && i < 8 )
-        OCL_ASSERT(((U*)buf_data[1])[i] == i );
+        OCL_ASSERT(((U*)buf_data[1])[i] == (U)i );
       else if(sizeof(U) == 2 && i < 16 )
-        OCL_ASSERT(((U*)buf_data[1])[i] == i );
+        OCL_ASSERT(((U*)buf_data[1])[i] == (U)i );
       else if(sizeof(U) == 4 && i < 32 )
-        OCL_ASSERT(((U*)buf_data[1])[i] == i );
+        OCL_ASSERT(((U*)buf_data[1])[i] == (U)i );
       else if(sizeof(U) == 8 && i < 64 )
-        OCL_ASSERT(((U*)buf_data[1])[i] == i );
+        OCL_ASSERT(((U*)buf_data[1])[i] == (U)i );
     }
   }
   else  // signed type
@@ -96,28 +96,28 @@ void test(const char *kernel_name, int s_type)
       if(sizeof(U) == 1)
       {
         if( i < 8 )
-          OCL_ASSERT(((U*)buf_data[1])[i] == i+1 );
+          OCL_ASSERT(((U*)buf_data[1])[i] == (U)i+1 );
         else if( i == 8 )
           OCL_ASSERT(((U*)buf_data[1])[i] == 0 );
       }
       else if(sizeof(U) == 2)
       {
         if( i < 16 )
-          OCL_ASSERT(((U*)buf_data[1])[i] == i+1 );
+          OCL_ASSERT(((U*)buf_data[1])[i] == (U)i+1 );
         else if( i == 16 )
           OCL_ASSERT(((U*)buf_data[1])[i] == 0 );
       }
       else if(sizeof(U) == 4)
       {
         if( i < 32 )
-          OCL_ASSERT(((U*)buf_data[1])[i] == i+1 );
+          OCL_ASSERT(((U*)buf_data[1])[i] == (U)i+1 );
         else if( i == 32 )
           OCL_ASSERT(((U*)buf_data[1])[i] == 0 );
       }
       else if(sizeof(U) == 8)
       {
         if( i < 63 )
-          OCL_ASSERT(((U*)buf_data[1])[i] == i+1 );
+          OCL_ASSERT(((U*)buf_data[1])[i] == (U)i+1 );
       }
     }
   }
diff --git a/utests/compiler_popcount.cpp b/utests/compiler_popcount.cpp
index c960ae6..c149690 100644
--- a/utests/compiler_popcount.cpp
+++ b/utests/compiler_popcount.cpp
@@ -51,7 +51,7 @@ void test(const char *kernel_name, int s_type)
   OCL_MAP_BUFFER(1);
   OCL_ASSERT(((T*)buf_data[1])[0] == 0);
   for (int i = 1; i < n; ++i){
-    OCL_ASSERT(((T*)buf_data[1])[i] == n-i-s_type);
+    OCL_ASSERT(((T*)buf_data[1])[i] == (T)n-i-s_type);
   }
   OCL_UNMAP_BUFFER(1);
 }
-- 
2.1.0



More information about the Beignet mailing list