From 3f043de4f7bb51cc4843f86ed2292ca49900568e Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Tue, 22 Feb 2022 15:29:16 -0500 Subject: [PATCH] Fix a warning "integer conversion resulted in a change of sign" We do (1 << 31). The problem is that MAX_INT (which is 2147483647) is smaller than that, which leads to overflow. Despite that, `unsigned int N = 1 << 31;` produces correct result, same as `unsigned int N = 1u << 31;`. --- src/details/ArborX_DetailsMortonCode.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/details/ArborX_DetailsMortonCode.hpp b/src/details/ArborX_DetailsMortonCode.hpp index 9a9c4ef17..eefa2b5e8 100644 --- a/src/details/ArborX_DetailsMortonCode.hpp +++ b/src/details/ArborX_DetailsMortonCode.hpp @@ -79,7 +79,7 @@ KOKKOS_INLINE_FUNCTION unsigned int morton32(float x, float y) { // The interval [0,1] is subdivided into 65,536 bins (in each direction). - constexpr unsigned N = (1 << 16); + constexpr unsigned N = (1u << 16); using KokkosExt::max; using KokkosExt::min; @@ -95,7 +95,7 @@ KOKKOS_INLINE_FUNCTION unsigned int morton32(float x, float y, float z) { // The interval [0,1] is subdivided into 1024 bins (in each direction). - constexpr unsigned N = (1 << 10); + constexpr unsigned N = (1u << 10); using KokkosExt::max; using KokkosExt::min; @@ -114,7 +114,7 @@ unsigned long long morton64(float x, float y) { // The interval [0,1] is subdivided into 2,147,483,648 bins (in each // direction). - constexpr unsigned N = (1 << 31); + constexpr unsigned N = (1u << 31); using KokkosExt::max; using KokkosExt::min; @@ -133,7 +133,7 @@ KOKKOS_INLINE_FUNCTION unsigned long long morton64(float x, float y, float z) { // The interval [0,1] is subdivided into 2,097,152 bins (in each direction). - constexpr unsigned N = (1 << 21); + constexpr unsigned N = (1u << 21); using KokkosExt::max; using KokkosExt::min;