title: Problems with Memmove and SIGSEGV in C
body: <p>I am having some issues with a memmove in C. As far as I can tell, both locations are valid memory addresses, I am able to print the contents of both memory locations before I perform the memmove, however as soon as I attempt to memmove, the function crashes with a SIGSEGV.</p>
  
  <p>Here is the code in question:</p>
  
  <pre><code>std::cout &lt;&lt; page[0] &lt;&lt; "\n";
  std::cout &lt;&lt;page[1] &lt;&lt; "\n" ;
  std::cout &lt;&lt; cache[index][cache_itr] &lt;&lt; "\n";
  
  memmove(cache[index][cache_itr],page,sizeof(float));
  
  //These lines never print.
  std::cout &lt;&lt; cache[index][cache_itr] &lt;&lt; "\n";
  std::cout &lt;&lt; cache[index][cache_itr] &lt;&lt; "\n";
  </code></pre>
  
  <p>The cache is declared as a float** , and page is a float* which contains a variable size array of floats. The size of the array being an issue is unlikely however, as I cannot even get it to copy over a single float, despite the fact that page undoubtedly contains a float, as evidenced by a valid print out of both page[0] and page[1].</p>
  
  <p>Cache[0] and Cache[1] (index will only ever be 0 or 1, this is also confirmed) are both pointers to a previously calloc-ed cache of float** within a struct object. This can be seen here:</p>
  
  <pre><code>float** cache[2];
  cache[0] = queryOb-&gt;cache;
  cache[1] = cache[0] + sizeOfCache/2;
  </code></pre>
  
  <p>Where sizeOfCache is initially used to declare how many blocks of size float* we want to calloc for queryOb->cache.</p>
  
  <p>I can't figure out for the life of me why this memmove is producing a sigsegv, I believe it might be to do with the memmove from a float* to a float** however I thought using the two indices on the memmove would cause it to start copying to the correct location.</p>
  
  <p>Any help would be much appreciated!</p>