Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:34:12+00:00 2026-06-11T01:34:12+00:00

Compiling with VS2012 and working with the DirectXMath library, I encountered an issue where

  • 0

Compiling with VS2012 and working with the DirectXMath library, I encountered an issue where it appeared that the compiler wasn’t aligning my XMMATRIX. I simplified the issue down to the following.

#include <DirectXMath.h>
using namespace DirectX;

int _tmain(int argc, _TCHAR* argv[])
{
  auto m1 = XMMatrixIdentity();
  auto m2 = XMMatrixIdentity();

  auto t1 = XMMatrixTranspose( m1 ); // sometimes access violation occurs here
  auto t2 = XMMatrixTranspose( m2 ); // or sometimes here

  return 0;
}

Re-running the code over and over will sometimes cause an “Access violation reading location 0xFFFFFFFF” on the first transpose, sometimes on the second.

I’ve figured out this is due to the fact that m1 and m2 are not being properly aligned. Replacing “auto” with “XMMATRIX” seems to solve the issue, so my suspicion is a compiler bug, but its also possible that I’m doing something wrong, or not enabling some option.

Is there something wrong with my code or is this a compiler bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:34:13+00:00Added an answer on June 11, 2026 at 1:34 am

    The definition for XMMATRIX has the following in the header file (xnamath.h), although this could be different in your version.

    // Matrix type: Sixteen 32 bit floating point components aligned on a
    // 16 byte boundary and mapped to four hardware vector registers
    #if (defined(_XM_X86_) || defined(_XM_X64_)) && defined(_XM_NO_INTRINSICS_)
    typedef struct _XMMATRIX
    #else
    typedef _DECLSPEC_ALIGN_16_ struct _XMMATRIX
    #endif
    

    So XMMATRIX is defined with __declspec(align(16)) (if you look through the header files it does reduce to this), which is a Microsoft specific extension. It’s not a macro. This means it’s a compiler bug, the compiler is failing to propagate these proprietary attributes to variables defined with the auto keyword.

    It’s probably best to just avoid the use of the auto keyword in this case, it’s probably neater than explicitly adding the declspec yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on VS2010, Crystal Reports. While compiling my code I am getting
In compiling qt I found that there is a qws target called arm-linux-gcc. I
When compiling a c file that uses old style function definition like int foo(a)
Howdy, I'm having a bit of an issue runnning a NAnt script that used
I am using a COM visible C# library that I call from VBA in
Compiling a file that uses OpenGL with Visual C++, when I try to include
Compiling the same code on two different machines. We have int functions that are
I am beginning on MySQL, and I encountered the error message while compiling the
Does C# compiler (in VS2008 or VS2010) remove unused methods while compiling ? I
Compiling a kernel module on 32-Bit Linux kernel results in __udivdi3 [mymodule.ko] undefined! __umoddi3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.