[eigen] Compile warnings 3.2.0-beta1: Implicit conversion loses integer precision

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hello all,

when compiling my SparseBlockMatrix experiments using Eigen-3.2.0-beta1 (using default 32-bit indices)
with clang++ (Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)) I get a few warnings
about implicitly truncating integers, e.g.

eigen-3.2.0/Eigen/src/SparseCore/SparseMatrix.h:314:32: warning: implicit conversion loses integer precision: 'ptrdiff_t' (aka 'long') to 'Index' (aka 'int') [-Wshorten-64-to-32]
          m_innerNonZeros[j] = innerNNZ;
                             ~ ^~~~~~~~
=> should probably static_cast<Index>() here?

eigen-3.2.0/Eigen/src/SparseCore/SparseMatrix.h:330:29: warning: implicit conversion loses integer precision: 'const long' to 'Index' (aka 'int') [-Wshorten-64-to-32]
          Index toReserve = std::max<std::ptrdiff_t>(reserveSizes[j], alreadyReserved);
                ~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=> I'm not sure why the std::max uses ptrdiff_t instead of Index here?

eigen-3.2.0/Eigen/src/SparseCore/SparseMatrix.h:1092:35: warning: implicit conversion loses integer precision: 'const long' to 'Index' (aka 'int') [-Wshorten-64-to-32]
    reserve(SingletonVector(outer,std::max<std::ptrdiff_t>(2,innerNNZ)));
            ~~~~~~~~~~~~~~~       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=> Same as above, I'm not sure why the std::max uses ptrdiff_t instead of Index here?

eigen-3.2.0/Eigen/src/Core/Assign.h:288:25: warning: implicit conversion loses integer precision: 'Index' (aka 'long') to 'int' [-Wshorten-64-to-32]
        ::run(dst, src, outer);
                        ^~~~~
=> no idea about this one.

I'm not sure whether they are new (due to the beta status), but it might be an option to cast explicitly (it is done in some places already).



Best regards

Daniel Vollmer

--------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
German Aerospace Center
Institute of Aerodynamics and Flow Technology | Lilienthalplatz 7 | 38108 Braunschweig | Germany


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/