title: free a cast pointer
body: <p>I want to know if it is ok to free() a pointer cast to another type.
  For instance if I do this:</p>
  
  <pre><code>char *p = malloc (sizeof (int));
  int *q = (int *)p;
  free (q);
  </code></pre>
  
  <p>I get no warning on gcc (-Wall).</p>
  
  <p>On linux, the man pages on free says it is illegal to call free on a pointer that was not returned by malloc(), calloc() or realloc(). But what happens if the pointer was cast to another type in between?</p>
  
  <p>I ask this because I read that the C standard does not require different pointer types (e.g. int* and char*) to have the same size, and I fail to understand how this is possible since they both need to be convertible to a void* in order to call the malloc/free functions.</p>
  
  <p>Is the above code legal?</p>