[eigen] Failing stable_norm_1 test

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


I just spent some time on the stable_norm_1 test, which fails on both my computer and Gael's computer when using gcc 4.3. It looks similar to the issue which you solved by the empty struct magic (well done!).

The details are as follows. I constructed the following (fairly) minimal test example:

#include <iostream>
#include <Eigen/Dense>

int main()
  Eigen::Matrix<float,1,1> v;
  v(0,0) = 0.1;
  std::cerr << "blue norm = " << v.colwise().blueNorm() << "\n";
  std::cerr << "status = " << v.colwise().hypotNorm().isApprox(v.colwise().norm(), 1e-4) << "\n";

When compiling with g++ (version 4.3.3) -O2 -g and running under valgrind, this produces:

Use of uninitialised value of size 4
    at 0x8048F28: bool Eigen::DenseBase<Eigen::PartialReduxExpr<Eigen::Matrix<float, 1, 1, 0, 1, 1>, Eigen::ei_member_hypotNorm<float>, 0> >::isApprox<Eigen::PartialReduxExpr<Eigen::Matrix<float, 1, 1, 0, 1, 1>, Eigen::ei_member_norm<float>, 0> >(Eigen::DenseBase<Eigen::PartialReduxExpr<Eigen::Matrix<float, 1, 1, 0, 1, 1>, Eigen::ei_member_norm<float>, 0> > const&, float) const (in /scratch/1/users/jitse/work/c/eigen/eigenfoo)
    by 0x8048AF5: main (in /scratch/1/users/jitse/work/c/eigen/eigenfoo)

and the same error with the same stack trace a bit later, at 0x8048F2A.

The result of the program is also wrong: it should print status = 1, but it says status = 0.

The error goes away when compiling with -fno-strict-aliasing.
I tried compiling with -Wstrict-aliasing=2 but that does not produce any warnings.

Over to the gurus!


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