[Mesa-dev] [PATCH mesa] vma/tests: cast away implementation detail of using strtoul()

Eric Engestrom eric.engestrom at intel.com
Tue Jun 5 17:13:31 UTC 2018

On MacOS, the build fails because of a compiler complaint about
a downcast:

  vma_random_test.cpp:239:18: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'uint_fast32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
     random_test r{seed};
  vma_random_test.cpp:239:18: note: insert an explicit cast to silence this issue
     random_test r{seed};
                   static_cast<uint_fast32_t>( )

Let's take the compiler's suggestion, as we only needed a long here to
use strtoul().

Cc: Scott D Phillips <scott.d.phillips at intel.com>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
 src/util/tests/vma/vma_random_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/tests/vma/vma_random_test.cpp b/src/util/tests/vma/vma_random_test.cpp
index 88beb0838614acadbb34..da3f9de1669aa47e56ce 100644
--- a/src/util/tests/vma/vma_random_test.cpp
+++ b/src/util/tests/vma/vma_random_test.cpp
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
       errx(1, "USAGE: %s seed iter_count\n", argv[0]);
-   random_test r{seed};
+   random_test r{static_cast<uint_fast32_t>(seed)};

More information about the mesa-dev mailing list