Created attachment 129 [details]
compiler output with warnings
With Microsoft Visual Studio 2008 and Eigen 3.0-beta4, I get the the mentioned warning (see attached compiler output). My code is pretty unsuspicious and it compiled without warnings with Eigen 3.0-beta3.
This is the affected file (with line numbers):
655: Vector4f V = es.eigenvectors().col(0).real();
656: Quaternionf quat(V.x(), V.y(), V.z(), V.w());
815: Vector3f dir(direction);
817: Vector3f z(0.f, 0.f, 1.f);
818: Vector3f axis = z.cross(dir);
OK, the line of code in question at OrthoMethods.h:46 is:
const typename internal::nested<Derived,2>::type lhs(derived());
This is a typedef so really this warning that you're getting is bogus. Actually it's already in our list of stupid warnings that we disable inside of Eigen, but we don't disable it outside of Eigen. If you want such known-stupid warnings to be permanently disabled, define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS before including Eigen headers.
Created attachment 199 [details]
path that fixes the warning
The patch adds the const keyword to all versions of the internal::nested<T>::type definition and removes it from all places where internal::nested<T>::type is used.
As described in my post to the mailing list , I think this warning is legitimate. I have attached a patch that moves the const keyword to the type definition.
A few words on the patch: right now, internal::nested<T>::type always evaluates either to a reference to a const object or to a plain object, but never to a reference to a mutable object. internal::nested<T>::type is sometimes used with the const keyword, sometimes without. After the patch, the const is moved to the type definition, so that all local variables for evaluated nested expressions will be const.
Results of the tests with the patch applied: all 21 failtests passed, 560 tests passed, 16 tests did not build (error C2719: formal parameter with __declspec(align('16')) won't be aligned), and 1 test failed (qr_colpivoting3, random failure, cannot reproduce).
First of all, this nested<> template will go away with bug 99. Marking as dependent.
This warning is not stupid, it just says that the const keyword in this context is useless. You are actually using a reference to a non-const object. g++ does the same thing even if it doesn't complain.
Here the constness of the type in question depends on template parameters. In other cases the type may not be const-qualified already. Hence the const keyword here is not useless. Right?
It seems all those had been fixed meanwhile:
Re-open if any problem persists.
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/218.