PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6.18k stars 1.23k forks source link

Compiler Warnings: Implicit Type and Value conversions #3339

Open dgovil opened 1 month ago

dgovil commented 1 month ago

Description of Issue

A few tests have issues with implicit type conversions. These seem benign but would be useful if someone could correct them and verify that they work as expected. It's a good first issue for someone new to USD to help contribute to USD and get used to the testing frameworks.

I am building with Clang 16 from Xcode 16 with python3 ./build_scripts/build_usd.py ~/Downloads/usd --build-variant debug --no-imaging -vvv but this should reproduce with other compilers. The warnings are reproduced below:


[4166/4632] Building CXX object pxr/imaging/hd/CMakeFiles/testHdSortedIdsPerf.dir/testenv/testHdSortedIdsPerf.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/imaging/hd/testenv/testHdSortedIdsPerf.cpp:48:32: warning: implicit conversion from 'const size_t' (aka 'const unsigned long') to 'result_type' (aka 'unsigned int') changes value from 5109223000 to 814255704 [-Wconstant-conversion]
   48 |         std::mt19937 randomGen(seed);
      |                      ~~~~~~~~~ ^~~~
/Users/dhruvgovil/Projects/usd/pxr/imaging/hd/testenv/testHdSortedIdsPerf.cpp:266:26: warning: implicit conversion from 'long' to 'result_type' (aka 'unsigned int') changes value from 5109223000 to 814255704 [-Wconstant-conversion]
  266 |         std::mt19937 gen(5109223000);
      |                      ~~~ ^~~~~~~~~~

4 warnings generated.
/Users/dhruvgovil/Projects/usd/pxr/imaging/hd/testenv/testHdSortedIdsPerf.cpp:48:32: warning: implicit conversion from 'const size_t' (aka 'const unsigned long') to 'result_type' (aka 'unsigned int') changes value from 5109223000 to 814255704 [-Wconstant-conversion]
   48 |         std::mt19937 randomGen(seed);
      |                      ~~~~~~~~~ ^~~~
/Users/dhruvgovil/Projects/usd/pxr/imaging/hd/testenv/testHdSortedIdsPerf.cpp:266:26: warning: implicit conversion from 'long' to 'result_type' (aka 'unsigned int') changes value from 5109223000 to 814255704 [-Wconstant-conversion]
  266 |         std::mt19937 gen(5109223000);
      |                      ~~~ ^~~~~~~~~~
jesschimein commented 1 month ago

Filed as internal issue #USD-10236