Sign in to follow this  

Using XMVECTOR as a class member causes a crash only in Release mode.

Recommended Posts

I've been trying to use XMVECTOR as a class member for a bounding box, since I do a lot of calculations, but I use the XMFLOAT3 only once per frame, so the bounding box has a method that gives me it's center in a XMFLOAT3, otherwise it stays in a XMVECTOR;The class is delcared with __declspec(align(16)) and works in debug mode.However in Release mode it crashes the instant I set it to something:


        Box& Box::operator=(const Box& box)
            _center = box._center;
            _extents = box._extents;
            return *this;



Whenever I do:


Box A;
Box B;
A = B;


It crashes, giving me 0xC0000005: Access violation reading location 0x00000000.
Also it crashes when I create it as a pointer:


Box* A = new Box();


This is the constructor:


            center = XMVectorZero();
            extents = XMVectorSplatOne();



Again, this works fine in Debug mode, but in Release it crashes.What could Release mode be changing that would generate invalid code?Do I need to do something else, other than aligning the box to 16 bytes?

Share this post

Link to post
Share on other sites

The only time I have ever heard of issues using this class is with respect to the 16 byte alignment.  Are you certain that you have correctly enforced the alignment?  I recall reading through the following page very closely when I ran into this issue some time ago: DirectXMath.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this