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

[SOLVED] unaligned assertion

Tags: None
(comma "," separated)
myguel
Registered Member
Posts
14
Karma
0

[SOLVED] unaligned assertion

Fri Feb 06, 2009 3:26 pm
Hello,
I have been trapped is the evil unaligned array assertion.

I have a structure A that have some Vector2d inside and I want a vector of A.
When I resize it, the assertion fails.

I read the web page and add all the stuffs but it seems to me that it is only useful if I use directly a std::vector of Vector2d and not a std::vector of A that contains a Vector2d.
Am I wrong?

What is the workaround?

Thanks a lot.

I use linux with a ubuntu 8.04, I have taken the tarball of the stable eigen-2.0, and I compile my code with g++-4.2

Here follows a minimal example of the problem:

#include
#include
#include
#include
#include

using namespace Eigen;

struct A
{
Vector2d point;
double o;


inline A()
:o(0.5)
{}


EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};


int main()
{

std::vector pleins;
pleins.resize(100); std::cout << "Fails" << std::endl;
}
User avatar
bjacob
Registered Member
Posts
658
Karma
3

[SOLVED] unaligned assertion

Fri Feb 06, 2009 3:40 pm
Hm OK you hit a really really bad corner case where you hit simultaneously 2 causes for this assertion.

Yes std::vector hits the same problem as std::vector because A contains a Vector2d.

We need to do something about that, please give us some time. Probably we should provide you with a macro to easily do the same with std::vector as we already do for std::vector.

Just FYI, #include does #include for you.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

[SOLVED] unaligned assertion

Fri Feb 06, 2009 4:40 pm
note that using:

Code: Select all
std::vector


will fix most of the trouble. Still remains the resize(int,T) issue...
User avatar
bjacob
Registered Member
Posts
658
Karma
3

[SOLVED] unaligned assertion

Fri Feb 06, 2009 6:32 pm
ggael wrote:Still remains the resize(int,T) issue...


I'm afraid this is a big issue... so we need to provide an easy way to add std::vector specializations for custom types.

EDIT: hm ok now that I read your message on the list, you're right, this is not practical, your solution is better.

Last edited by bjacob on Fri Feb 06, 2009 6:37 pm, edited 1 time in total.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
myguel
Registered Member
Posts
14
Karma
0

[SOLVED] unaligned assertion

Fri Feb 06, 2009 6:56 pm
ggael wrote:note that using:

Code: Select all
std::vector



is it in the last svn version, or do I have to include a special header ?
Because it does not even compile with the code I provide and the version of eigen, I use.

- Best regards,

by the way, the objectives of eigen are great, and as long as I use 3d object, everything works fine.
myguel
Registered Member
Posts
14
Karma
0

[SOLVED] unaligned assertion

Fri Feb 06, 2009 7:05 pm
Ok, sorry, I find the doc and the good code is:

Code: Select all
std::vector >
myguel
Registered Member
Posts
14
Karma
0

[SOLVED] unaligned assertion

Fri Feb 06, 2009 7:09 pm
Something is not very clear for, should I used the above code or the latter:
Code: Select all
std::vector >

because both compile and execute fine.

Thanks to clarify that.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

[SOLVED] unaligned assertion

Sat Feb 07, 2009 12:53 pm
btw, the correct version should be:
Code: Select all
std::vector >


However with latest trunk, simply doing:
Code: Select all
#include
//...
std::vector

should work fine now! (make sure you #include before including , or don't include at all)


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell