title: Interpreting valgrind error Invalid write of size 4
body: <p>I was recently trying to track down some bugs in a program I am working on using valgrind, and one of the errors I got was:</p>
  
  <pre><code>==6866== Invalid write of size 4
  ==6866==    at 0x40C9E2: superneuron::read(_IO_FILE*) (superneuron.cc:414)
  </code></pre>
  
  <p>the offending line # 414 reads</p>
  
  <pre><code>amplitudes__[points_read] = 0x0;
  </code></pre>
  
  <p>and amplitudes__  is defined earlier as </p>
  
  <pre><code>uint32_t * amplitudes__ = (uint32_t* ) amplitudes;
  </code></pre>
  
  <p>Now obviously a uint32_t is 4 bytes long, so this is the write size, but could someone tell me why it's invalid ?</p>