Access variable through memory location
<p>I get wrong value when accessing  variabel <code>v2</code> using their memory location when HWND is before bool variable. If Ii use HWND after bool then I get correct result. Using instance variable (<code>t</code>) I get correct value for <code>v1</code> and <code>v2</code> such as <code>t-&gt;v1</code> and <code>t-&gt;v2</code>. I am using Windows Server 2003. I have the following Test class. this is only reproducible in 64 bit OS; 32 bit OS work fine.</p>

<pre><code>#include "conio.h"
#include "stdio.h"
include "windows.h"
class Test
{
public :
 Test()
 {
  v1=12345678;
  v2=87654321;
 }

 HWND        hWnd;
 bool        MsgHandled;



 unsigned long v1;
 unsigned long v2;

};

int _tmain(int argc, _TCHAR* argv[])
{
 Test* t=new Test();
 unsigned long sign1 = *(unsigned long*)((unsigned char*)t + sizeof(Test)-2*sizeof(unsigned long));
 unsigned long sign2 = *(unsigned long*)((unsigned char*)t + sizeof(Test)-sizeof(unsigned long));

 printf("\nTest size %d",sizeof(Test));

 printf("\n t-&gt;v1 %d",t-&gt;v1);
 printf("\n t-&gt;v2 %d",t-&gt;v2);

 printf("\n v 1 %d",sign1);
 printf("\n v 2 %d",sign2); // garbage value in 64 bit os

 getch();
 return 0;
}
</code></pre>
