Member specialization of alias declaration in different namespaces : <p>I just encountered a strange difference in behavior between clang and gcc where I wanted to compile code which looks similar to the following:</p>

<pre class="lang-cpp prettyprint-override"><code>namespace n1 {
  template &lt;class T1, class T2&gt;
  struct MyTemplate {
    struct Inner {};
  };
}

using namespace n1;
namespace n2 {
  using MyClass = MyTemplate&lt;int, int&gt;;
}

namespace n1 {
  using n2::MyClass;
  template&lt;&gt; struct MyClass::Inner {
    int member;
  };

  MyClass::Inner inner{0};
}
</code></pre>

<p>Clang happily compiles this:</p>

<pre><code>$ clang++ -std=c++11 -c -o alias_specialization.o alias_specialization.cc
</code></pre>

<p>but gcc throws the following error: </p>

<pre><code>$ g++ -std=c++11 -c -o alias_specialization.o alias_specialization.cc

alias_specialization:15:30: error: declaration of ‘struct n1::MyTemplate&lt;int, int&gt;::Inner’ in namespace ‘n1’ which does not enclose ‘using MyClass = struct n1::MyTemplate&lt;int, int&gt;’
   template&lt;&gt; struct MyClass::Inner {
</code></pre>

<p>I know I can just write the full name of the original type (<code>MyTemplate&lt;int, int&gt;</code>) instead of <code>MyClass</code> in line 15.
But I'm simply wondering which of the two compilers is "right".
The exact compilers in use are:</p>

<pre><code>$ clang++ --version
clang version 4.0.0

$ g++ --version
g++ (GCC) 6.3.1 20170306
</code></pre>
