title: Different compiler behavior when applying a const qualifier to a template argument
body: <p>Consider the following example (<a href="https://godbolt.org/g/gzCzKi" rel="noreferrer">godbolt</a>):</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  const T *as_const(T *p) { return p; }
  
  void f() {}
  
  template &lt;typename T&gt;
  void g(T *) { std::cout &lt;&lt; "A"; }
  
  template &lt;typename T&gt;
  void g(const T *) { std::cout &lt;&lt; "B"; }
  
  int main() {
    g(as_const(&amp;f));
  }
  </code></pre>
  
  <p>Both GCC and Clang can compile it, but the resulting executables produce different output: the version compiled with GCC prints <code>A</code> and the one compiled with Clang prints <code>B</code>.</p>
  
  <p>Could you explain this difference?</p>
  
  <p><strong>Update</strong>: as pointed out by @VTT the same difference is observed even if <code>as_const</code> is dropped.</p>