Name lookup differences between g++ and MSVS
<p>Consider this code:</p>

<pre><code>#include &lt;iostream&gt;

namespace N {
    class A {};
    void f(A a) { std::cout &lt;&lt; "N::f\n"; }
}

void f(int i) { std::cout &lt;&lt; "::f\n"; }

template &lt;typename T&gt;
class Base {
  public:
    void f(T x) { std::cout &lt;&lt; "Base::f\n"; }
};


template &lt;typename T&gt;
class X : public Base&lt;T&gt; {
  public:
    void g() {
        T t;
        f(t);
    }
};

int main()
{
    X&lt;N::A&gt; x1;
    x1.g();

    X&lt;int&gt; x2;
    x2.g();
}
</code></pre>

<p>The code is intended to investigate how name lookup works in C++.</p>

<p>If I compile this program with GNU C++ (version 6.1.0), it prints:</p>

<pre><code>N::f
::f
</code></pre>

<p>But if I compile it with Microsoft Visual Studio 2015, it prints:</p>

<pre><code>Base::f
Base::f
</code></pre>

<p>Which is the correct behaviour, and why?</p>