title: Incompatible pointer type warning with const array parameter
body: <p>My understanding is that</p>
  
  <pre><code>char (*)[20]
  </code></pre>
  
  <p>is a <a href="https://stackoverflow.com/a/859650/1611055">pointer to an array of 20 <strong>non-const chars</strong></a>, while</p>
  
  <pre><code>const char (*)[20]
  </code></pre>
  
  <p>is a pointer to an array of 20 <strong>const chars</strong>.</p>
  
  <p>In the following code, I am passing a pointer to an array of <strong>non-const chars</strong> to a function which expects a pointer to an array of <strong>const chars</strong>. Inside the function, the compiler properly catches write accesses to the array, as expected:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  
  void f(const char (*param)[20]) {
     /* correctly catched by the compiler: assignment of read-only location '(*param)[2]' */
     /* (*param)[2] = 'A'; */
  }
  
  int main() {
     char (*data)[20] = calloc(20, 1);
  
     f(data);
  
     return 0;
  }
  </code></pre>
  
  <p>However, I am getting the following warning at the function call:</p>
  
  <pre><code>$ gcc -Wall -pedantic -o so so.c
  so.c: In function 'main':
  so.c:15:4: warning: passing argument 1 of 'f' from incompatible pointer type [enabled by default]
      f(data);
      ^
  so.c:3:6: note: expected 'const char (*)[20]' but argument is of type 'char (*)[20]'
   void f(const char (*param)[20]) {
        ^
  </code></pre>
  
  <p>Why is that? Should it not always be possible to pass a <strong>pointer to non-const data</strong> to a function which expects a <strong>pointer to const data</strong> of the same type? </p>
  
  <p>I know that there are <a href="https://stackoverflow.com/questions/4523497/typedef-fixed-length-array">other solutions</a> to this, but I am particularly interested in understanding why the compiler gives this warning in this specific situation.</p>