title: link error while compiling this "simple" program with clang and g++
body: <p>I am working on a project, and it seems that clang is unable to generate a valid bytecode (as the linker fail to link, some <code>static constexpr</code> in a template class is not found at link time)
  I can fix it with a static getter in the class, but this lead to some really ugly/overloaded code.</p>
  
  <p>Here is a "minimal" sample of code that makes the <em>bug</em> (is it a bug ?) appear.
  Unfortunately, here, g++ will produce the same link error.</p>
  
  <p>I'm asking if this is a compiler bug, or I am simply doing something wrong, and if there's a solution to avoid this error.
  (And if I am doing something wrong, <em>why</em> the <em>same</em> construct works in my bigger project ??)</p>
  
  <p><em><strong>NOTE</strong>: The bigger project is named <code>yaggler</code> on github, but is still at the early beginning of its life</em></p>
  
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;iostream&gt;
  
  // exemple vector classes
  struct vector2
  {
    constexpr vector2(unsigned int _x = 0, unsigned int _y = 0) : x(_x), y(_y) {} // for clang
  
    unsigned int x;
    unsigned int y;
  };
  struct vector3 : public vector2 // uh ;)
  {
    constexpr vector3(unsigned int _x = 0, unsigned int _y = 0, unsigned int _z = 0) : vector2(_x, _y), z(_z) {} // for clang
    unsigned int z;
  };
  
  // simple templated generic vector type
  // we could make a more generic one, but this would require something like a tuple.
  template&lt;unsigned int... Vals&gt;
  struct vector
  {
      static_assert(!(sizeof...(Vals) + 1), "[...]");
  };
  template&lt;unsigned int X&gt;
  struct vector&lt;X&gt;
  {
    using vec_type = unsigned int;
    static constexpr unsigned int value = X;
  };
  template&lt;unsigned int X, unsigned int Y&gt;
  struct vector&lt;X, Y&gt;
  {
    using vec_type = vector2;
    static constexpr vector2 value = vector2(X, Y);
  };
  template&lt;unsigned int X, unsigned int Y, unsigned int Z&gt;
  struct vector&lt;X, Y, Z&gt;
  {
    using vec_type = vector3;
    static constexpr vector3 value = vector3(X, Y, Z);
  };
  
  // a simple wrapper
  template&lt;typename V&gt;
  struct some_wrapper
  {
    static constexpr typename V::vec_type value = V::value;
  };
  
  // a dummy function that print something to stdout.
  void do_something(int32_t id, const vector3 &amp;value)
  {
    std::cout &lt;&lt; id &lt;&lt; " " &lt;&lt; value.z &lt;&lt; std::endl;
  }
  void do_something(int32_t id, const vector2 &amp;value)
  {
    std::cout &lt;&lt; id &lt;&lt; " " &lt;&lt; value.y &lt;&lt; std::endl;
  }
  void do_something(int32_t id, int value)
  {
    std::cout &lt;&lt; id &lt;&lt; " " &lt;&lt; value &lt;&lt; std::endl;
  }
  
  // the class used to create the error
  template&lt; typename... Args&gt;
  class exemple
  {
    private:
      // an initialisation that recurse over the Args... template arguments
      template&lt;typename Current, typename... Others&gt;
      void __rec_init() const
      {
        do_something(0, Current::value);
        __rec_init&lt;Others...&gt;();
      }
  
      // end of recursion
      template&lt;size_t = 0&gt;
      void __rec_init() const {}
  
      // launch the recursion
      void tpl_init() const
      {
        __rec_init&lt;Args...&gt;();
      }
  
    public:
      exemple()
      {
        tpl_init();
      }
  };
  
  int main()
  {
    // and here, we get a linker error.
    exemple&lt;some_wrapper&lt;vector&lt;4, 4, 5&gt;&gt;, some_wrapper&lt;vector&lt;4, 1&gt;&gt;, some_wrapper&lt;vector&lt;9&gt;&gt;&gt;();
  }
  </code></pre>
  
  <p><strong>EDIT</strong>: just to mention gcc and clang versions: gcc 4.7.3/4.8.2 and clang 3.2/3.3 </p>