Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Sock5   Members   -  Reputation: 162

Like
0Likes
Like

Posted 01 April 2013 - 04:24 PM

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:

 

        Box::Box()
        {
            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?


>removed<


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5282

Like
0Likes
Like

Posted 02 April 2013 - 09:20 PM

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.



#3 kubera   Members   -  Reputation: 963

Like
0Likes
Like

Posted 03 April 2013 - 12:20 AM

Please consider reading that answer:

 

http://xboxforums.create.msdn.com/forums/t/84299.aspx



#4 Sock5   Members   -  Reputation: 162

Like
0Likes
Like

Posted 03 April 2013 - 12:53 AM

Yeah, turns out you have to overload the new operator and use an aligned allocator for 16 bytes, fixed it for me.Thanks for the links.


>removed<





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS