Bug 581 - blueNorm() implementation produces an interesting warning from clang++
blueNorm() implementation produces an interesting warning from clang++
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Geometry
3.2
x86 - 64-bit All
: Normal Unknown
Assigned To: Nobody
:
Depends on:
Blocks: 3.2
  Show dependency treegraph
 
Reported: 2013-04-08 23:13 UTC by Kyle M. Tarplee
Modified: 2013-04-09 09:28 UTC (History)
3 users (show)



Attachments

Description Kyle M. Tarplee 2013-04-08 23:13:14 UTC
Clang issues a warning about implicit conversion from long to int in the blueNorm implementation.  The scary part about this warning is that the code is trying to find the largest int but ends up with -1 due to the implicit case.

This can be easily fixed by replacing the use of int on lines 48 and 79 with Index (which for my 64 bit mac is 64 bit).

In file included from /opt/local/include/eigen3/Eigen/Dense:1:
In file included from /opt/local/include/eigen3/Eigen/Core:294:
/opt/local/include/eigen3/Eigen/src/Core/StableNorm.h:93:13: warning: implicit conversion from 'type' (aka 'long') to 'int' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion]
    nbig  = (std::numeric_limits<Index>::max)();            // largest integer
          ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h:207:18: note: in instantiation of member function 'Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >::blueNorm' requested here
    dxnorm = wa2.blueNorm();
Comment 1 Kyle M. Tarplee 2013-04-08 23:13:46 UTC
The code for 3.2 also has this problem.
Comment 2 Gael Guennebaud 2013-04-09 09:28:06 UTC
Indeed, that might look scary, but fortunately this piece of code was actually useless, and that's why this mistake did not show up in our unit test. Thanks for the report.

https://bitbucket.org/eigen/eigen/commits/72a7ce1bca6d/
Changeset:   72a7ce1bca6d
User:        ggael
Date:        2013-04-09 09:23:40
Summary:     Fix bug 581: remove useless piece of code is blueNorm

https://bitbucket.org/eigen/eigen/commits/83ccf6713af3/
Changeset:   83ccf6713af3
Branch:      3.1
User:        ggael
Date:        2013-04-09 09:23:40
Summary:     Fix bug 581: remove useless piece of code is blueNorm
(transplanted from 72a7ce1bca6d88fb4bc788be628925bebdf0e037)

Note You need to log in before you can comment on or make changes to this bug.