title: C++ - Generic struct's members give wrong values when assigning doubles (but works fine with integers)
body: <p>I have a generic struct like the following (inside of a generic template):</p>
  
  <pre><code>struct AY_ALIGN(64) {
      T parm1;
      T parm2;
      T parm3;
      T parm4;
      T parm5;
  };
  </code></pre>
  
  <p>When I assign the members with integers, the output is correct:</p>
  
  <pre><code>pr-&gt;u.p.parm1 = 0;
  pr-&gt;u.p.parm2 = 2;
  pr-&gt;u.p.parm3 = 1;
  pr-&gt;u.p.parm4 = 1;
  pr-&gt;u.p.parm5 = 1;
  
  printf("The values: parm1=%i, parm2=%i, parm3=%i, parm4=%i, parm5=%i.\n",
          pr-&gt;u.p.parm1,
          pr-&gt;u.p.parm2,
          pr-&gt;u.p.parm3,
          pr-&gt;u.p.parm4,
          pr-&gt;u.p.parm5);
  </code></pre>
  
  <p>The printf() here gives the correct values.</p>
  
  <p><strong>The problem happens, when using doubles like this:</strong></p>
  
  <pre><code>*(double *)&amp;pr-&gt;u.p.parm1 = 1.0;
  *(double *)&amp;pr-&gt;u.p.parm2 = 2.0;
  *(double *)&amp;pr-&gt;u.p.parm3 = 1.0;
  *(double *)&amp;pr-&gt;u.p.parm4 = 1.0;
  *(double *)&amp;pr-&gt;u.p.parm5 = 1.0;
  
  printf("The values: parm1=%f, parm2=%f, parm3=%f, parm4=%f, parm5=%f.\n",
          *(double *)&amp;pr-&gt;u.p.parm1,
          *(double *)&amp;pr-&gt;u.p.parm2,
          *(double *)&amp;pr-&gt;u.p.parm3,
          *(double *)&amp;pr-&gt;u.p.parm4,
          *(double *)&amp;pr-&gt;u.p.parm5);
  </code></pre>
  
  <p>The output here is:</p>
  
  <pre><code>parm1=0.000000
  parm2=0.000000
  parm3=0.000000
  parm4=0.000000
  parm5=1.000000
  </code></pre>
  
  <p>And when using other numbers like parm4=0.8754 (just an example), the output changes to very strange:</p>
  
  <pre><code>parm1=1.000000
  parm2=0.000000
  parm3=-85443653999189573105674489609599978349239364506618107894018364220379126235920356559839098648677109228247196955211621648453249973580988416.000000
  parm4=0.000000
  parm5=1.000000
  </code></pre>
  
  <p>Any idea what I am missing here?</p>