title: C++ and IBM compiler bug?
body: <p>Very interesting piece of code here. I have created it with the only purpose - to demonstrate the behaviour of the xlC compiler. </p>
  
  <pre><code>namespace ns {
      template&lt;typename T&gt; inline T f() { return T(); }
      template&lt;&gt; inline double f&lt;double&gt;() { return 0.001; } // test specialization
  };
  template&lt;typename T &gt;
  class A1 {
      public: A1( const T&amp; arg = ns::f&lt;T&gt;() ) {};
  };
  template&lt;typename T&gt;
  class D1 {
      public: D1(T t = 0) : t_(t) {};
      private: T t_;
  };
  class my {
      A1&lt; D1&lt;int&gt; &gt; a;
  
      public: my() ;
  };
  
  //namespace ns { template&lt;&gt; D1&lt;int&gt;  f&lt;D1&lt;int&gt; &gt;() { return D1&lt;int&gt;(); } }
  
  my::my() { };
  
  void ff() {
      my m;
      A1&lt;double&gt; ad;
  }
  </code></pre>
  
  <p>If you compile this code as it is, it's causing a compilation error:</p>
  
  <pre><code>!$ xlC -c b.cpp 
  "b.cpp", line 7.40: 1540-0253 (S) This use of undefined class "D1&lt;int&gt;" is not valid.
  "b.cpp", line 22.10: 1540-1205 (I) The error occurred while converting to parameter 1 of         "A1&lt;D1&lt;int&gt; &gt;::A1(const D1&lt;int&gt; &amp;)".
  !$ xlC -qversion
  IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)
  
  !$ uname -a
   AIX build25 1 6 00C8B3424C00 powerpc AIX
  </code></pre>
  
  <p>And now, if we uncomment the line started with the "//namespace" (which is nothing else but template specialization for the typename D1&lt; int>, compiler error disappears.</p>
  
  <p>Gnu compiler seems to have no problem with it. Does any of you have an idea?</p>
  
  <p>PS. The problem was found of course in a real project and this is just a simplified example. In real project, there are hundreds of classes like D1&lt; int>. They suppose to work out of the box. But for xlC I have to write the specialized functions for each particular case. That hurts a lot ...</p>