Calling a function with a non-const pointer reolves to a template function over a function taking a pointer to const
<p>The following code was compiled on g++ 4.1.2 and g++ 4.4.4.  Both give the results noted in the comments.</p>

<pre><code>int f(const int * a)
{
   return 0;
}

template&lt;typename A&gt;
int f(A a)
{
   return 1;
}

int main()
{
    int x;
    // return f(&amp;x); // returns 1
    return f((const int *)&amp;x); // returns 0
}
</code></pre>

<p>It appears to boil down to a call of <code>f(int *)</code> resolves to <code>f&lt;int *&gt;(int *)</code> instead of the expected <code>f(const int *)</code>.  I found this shocking and completely unintuitive.  </p>

<p>Is this a bug in g++, a dark corner of C++, or obvious for some reason I am missing?  If it's not a bug, what's the theory or logic behind it?  Are there any safe practices regarding this issue?</p>
