title: Allocating memory for a double array using uint8_t
body: <p>I have a uint8_t array of memory allocated dynamically</p>
  
  <pre><code>uint8_t* array = malloc( sizeof( double ) * 100 );
  </code></pre>
  
  <p>I want to store doubles into the memory. Would this be considered defined behaviour, or is there some alignment issue I would have to worry about?</p>
  
  <pre><code>double* d = ( void* )array ;
  
  for( int i = 0 ; i &lt; 100 ; i++ )  
      d[i] = 3.1415 ;    //any double will do here
  </code></pre>
  
  <p><code>d</code> should behave identically as if I would just allocate d as :</p>
  
  <pre><code>double* d = malloc( sizeof( double ) * 100 );
  </code></pre>
  
  <p>Also if I change the pointer array to point further into memory like this:</p>
  
  <pre><code> double* d = ( void* )(array + sizeof( double ) * 50 ) ;
   for( int i = 0 ; i &lt; 50; i++ )  
      d[i] = 3.1415 ;    //any double will do here
  </code></pre>
  
  <p>would the <code>d</code> behave identically as </p>
  
  <pre><code>double* d = malloc( sizeof( double ) * 50);
  </code></pre>
  
  <p>( how to correctly free the memory is not the issue here )</p>