title: Is it a good practice to free memory via a pointer-to-const
body: <p>There are many questions discussing the details of C and C++ dealing with pointer-to-const deletion, namely that <code>free()</code> does not accept them and that <code>delete</code> and <code>delete[]</code> do and that constness doesn't prevent object destruction.</p>
  
  <p>What I am interested on is whether you think it is a good practice to do so, not what the languages (C and C++) allow.</p>
  
  <p>Arguments for pointer-to-const deletion include:</p>
  
  <ul>
  <li>Linus Torvalds' <code>kfree()</code>, unlike C's <code>free()</code>, takes a <code>void const*</code> argument because he thinks that freeing the memory does not affect what is pointed to.</li>
  <li><code>free()</code> was designed before the introduction of the const keyword.</li>
  <li>C++'s delete operators allow deletion of const data.</li>
  </ul>
  
  <p>Arguments against it include:</p>
  
  <ul>
  <li>Programmers do not expect data to be modified (or deleted) when they pass a pointer-to-const to it.</li>
  <li>Many think that pointer-to-const implies not getting ownership of the data (but not that non-const would imply getting ownership).</li>
  <li>This is the common practice seen in most libraries and existing code.</li>
  </ul>
  
  <p>Please argument well in your responses and possibly refer to authorities. My intention is not to start a poll here.</p>