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

Unexpected behaviour with redefined assertion

Tags: None
(comma "," separated)
mmwind
Registered Member
Posts
2
Karma
0
Hi all,
I redefined assertions to throw exception the following way:
Code: Select all
#undef eigen_assert
#define eigen_assert(x) \
  if (!x) { \
     std::string s = std::string(__FILE__) + std::string(" : ") + std::string(__FUNCTION__) + std::string(" : ") + std::string(EIGEN_MAKESTRING(x)); \
     throw (std::runtime_error(s.c_str() )); }

In this case simplest code above returns exception in VectorXd constructor with message "Eigen/src/Core/Matrix.h : Matrix : dim >= 0".
But it does not produce assert without assertion redefinement. Furthermore, if I ignore this exception, other parts of vector initialization works well (memory was allocated properly).
Code: Select all
using namespace std;
using namespace Eigen;

int main(){
   try{
          VectorXd v(3);
          v << 1, 2, 3;
          cout << "v =" << endl <<  v << endl;
   } catch(std::runtime_error &e){
          std::cout << e.what() << std::endl;
   }
     return(0);
}

How can I redefined assertion in right way?
I will be very appreciated for help with that trouble.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
common macro mistake, it should be:
Code: Select all
...
if (!(x))
...
mmwind
Registered Member
Posts
2
Karma
0
ggael wrote:common macro mistake, it should be:
Code: Select all
...
if (!(x))
...


Thank you for help and cool library!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora