title: C++: Strange "is private" error
body: <p>I've been getting a very unusual error from g++ claiming that a type alias is private. After hours of reducing my code, I've arrived at the following minimal test case:</p>
  
  <pre><code>template &lt;typename Dummy&gt;
  class Test {
      struct CatDog {
          static void meow ()
          {
              CrazyHouse::TheCatDog::meow();
          }
  
          struct Dog {
              static void bark ();
          };
      };
  
      struct CrazyHouse {
          using TheCatDog = CatDog;
  
          static void startMadness ()
          {
              TheCatDog::meow();
              TheCatDog::Dog::bark();
          }
      };
  
  public:
      static void init ()
      {
          CrazyHouse::startMadness();
      }
  };
  
  int main ()
  {
      Test&lt;void&gt; t;
      t.init();
  }
  </code></pre>
  
  <p>The error with g++ 4.8.2 is:</p>
  
  <pre><code>test.cpp: In instantiation of 'static void Test&lt;Dummy&gt;::CatDog::meow() [with Dummy = void]':
  test.cpp:19:29:   required from 'static void Test&lt;Dummy&gt;::CrazyHouse::startMadness() [with Dummy = void]'
  test.cpp:27:34:   required from 'static void Test&lt;Dummy&gt;::init() [with Dummy = void]'
  test.cpp:34:12:   required from here
  test.cpp:15:33: error: 'using TheCatDog = struct Test&lt;void&gt;::CatDog' is private
           using TheCatDog = CatDog;
                                   ^
  test.cpp:6:41: error: within this context
               CrazyHouse::TheCatDog::meow();
                                           ^
  </code></pre>
  
  <p>Clang 3.4 accepts the same code. What's going on here, is this a g++ bug?</p>
  
  <p>Doing any of the following stops the error from occuring:</p>
  
  <ul>
  <li>Turning <code>Test</code> into a class, as opposed to a template class.</li>
  <li>Removing any of the statements in any of the functions.</li>
  <li>Changing <code>TheCatDog::Dog::bark();</code> to <code>CatDog::Dog::bark();</code>.</li>
  <li>Removing the <code>CrazyHouse</code> class and merging its contents in <code>Test</code>.</li>
  <li>Removing the <code>CatDog</code> class, merging its contents into <code>Test</code> and changing the <code>TheCatDog</code> alias to point to <code>Test</code>.</li>
  </ul>