title: Why does MISRA C state that a copy of pointers can cause a memory exception?
body: <p>MISRA C 2012 directive 4.12 is "Dynamic memory allocation should not be used".</p>
  
  <p>As an example, the document provides this sample of code:</p>
  
  <pre><code>char *p = (char *) malloc(10);
  char *q;
  
  free(p);
  q = p; /* Undefined behaviour - value of p is indeterminate */
  </code></pre>
  
  <p>And the document states that:</p>
  
  <blockquote>
    <p>Although the value stored in the pointer is unchanged following the
    call to free, it is possible, on some targets, that the memory to
    which it points no longer exists <strong>and the act of copying that pointer</strong>
    <strong>could cause a memory exception</strong>.</p>
  </blockquote>
  
  <p>I'm ok with almost all the sentence but the end. As p and q are both allocated on the stack, how can the copy of the pointers cause a memory exception ?</p>