This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Exception in the destructor of CommaInitializer

Tags: None
(comma "," separated)
drolevar
Registered Member
Posts
1
Karma
0
Hi all,

I have found that if eigen_assert is configured to throw an exception, and this exception occurs when using CommaInitializer, then the exception occurs also in the destructor of the CommaInitializer, making impossible exception handling.

Like in the following example:

Code: Select all
#define MAKESTRING2(a) #a
#define MAKESTRING(a) MAKESTRING2(a)

#define eigen_assert(x) if (!(x)) { throw std::exception("Eigen error: " MAKESTRING(x)); }

#include <Eigen/Core>

int main()
{
   try
   {
      Eigen::MatrixXd mtr(3, 4);
      mtr << 1, 2, 3, 11,
         4, 5, 6, 12,
         7, 8, 9, 13;

      Eigen::VectorXd vec(4);
      // This line will cause exception
      vec << 1, 2, 3, 11, 15;

      auto res = vec * mtr;

      std::cout << res.cols() << res.rows();
   }
   catch (std::exception& e)
   {
      std::cout << e.what();
   }

   return 0;
}


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]