DrTimothyAldenDavis / GraphBLAS

SuiteSparse:GraphBLAS: graph algorithms in the language of linear algebra. For production: (default) STABLE branch. Code development: ask me for the right branch before submitting a PR. video intro: https://youtu.be/Tj5y6d7FegI .
http://faculty.cse.tamu.edu/davis/GraphBLAS.html
Other
345 stars 61 forks source link

Compiler sign compare warning in `GxB_Vector_Iterator_seek` #300

Open alugowski opened 3 weeks ago

alugowski commented 3 weeks ago

Build command:

clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -g -arch arm64 -I/usr/local/include -I/usr/local/include/suitesparse -I/private/var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T/cibw-run-bykdd6ur/cp312-macosx_arm64/build/venv/include -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c build/temp.macosx-11.0-arm64-cpython-312/suitesparse_graphblas._graphblas.c -o build/temp.macosx-11.0-arm64-cpython-312/build/temp.macosx-11.0-arm64-cpython-312/suitesparse_graphblas._graphblas.o

Warning

    build/temp.macosx-11.0-arm64-cpython-312/suitesparse_graphblas._graphblas.c:65372:10: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int64_t' (aka 'long long') [-Wsign-compare]
      return GxB_Vector_Iterator_seek(x0, x1);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/suitesparse/GraphBLAS.h:11822:5: note: expanded from macro 'GxB_Vector_Iterator_seek'
        GB_Vector_Iterator_seek (iterator, p)                                   \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/suitesparse/GraphBLAS.h:11799:8: note: expanded from macro 'GB_Vector_Iterator_seek'
        (q >= iterator->pmax) ?                                                 \
         ~ ^  ~~~~~~~~~~~~~~
    build/temp.macosx-11.0-arm64-cpython-312/suitesparse_graphblas._graphblas.c:65405:14: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'int64_t' (aka 'long long') [-Wsign-compare]
      { result = GxB_Vector_Iterator_seek(x0, x1); }
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/suitesparse/GraphBLAS.h:11822:5: note: expanded from macro 'GxB_Vector_Iterator_seek'
        GB_Vector_Iterator_seek (iterator, p)                                   \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/include/suitesparse/GraphBLAS.h:11799:8: note: expanded from macro 'GB_Vector_Iterator_seek'
        (q >= iterator->pmax) ?                                                 \
         ~ ^  ~~~~~~~~~~~~~~
    2 warnings generated.
DrTimothyAldenDavis commented 3 weeks ago

Got it. I'll replace q with an explicit typecast to ((int64_t) q)

DrTimothyAldenDavis commented 2 weeks ago

See https://github.com/DrTimothyAldenDavis/GraphBLAS/commit/2e8c62e36fae9b83c442a87420c30a9e5fb25015 . It passes all my tests (not github CI tests, but my GraphBLAS/Tcov and GraphBLAS/@GrB tests, which require MATLAB).

I'll add this to the 9.3.0 release.