<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang requires a typedef when declaring and initializing a templated member variable"
   href="http://llvm.org/bugs/show_bug.cgi?id=17610">17610</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang requires a typedef when declaring and initializing a templated member variable
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mjbshaw@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When using the Eigen library, I found a bug in the C++11 clang front-end, which
is visible in this minimal example:

template <typename T, int x, int y>
struct M;

template <>
struct M<float, 3, 3>
{
    static M<float, 3, 3> bar()
    {
        return {};
    }
};

typedef M<float, 3, 3> M3f;

struct Foo
{
    //M<float, 3, 3> m = M3f::bar(); // Works
    M<float, 3, 3> m = M<float, 3, 3>::bar(); // Does not work
};

int main() {}



I expected this to compile just fine, however, I get the following errors when
compiling:

$ clang++ -std=c++11 -stdlib=libc++ mat.cpp 
mat.cpp:18:33: error: expected member name or ';' after declaration specifiers
    M<float, 3, 3> m = M<float, 3, 3>::bar();
    ~~~~~~~~~~~~~~              ^
mat.cpp:18:32: error: expected ';' at end of declaration list
    M<float, 3, 3> m = M<float, 3, 3>::bar();
                               ^
                               ;
mat.cpp:18:31: error: expected '>'
    M<float, 3, 3> m = M<float, 3, 3>::bar();
                              ^
3 errors generated.



This very same code compiles fine on GCC: <a href="http://ideone.com/ttadC1">http://ideone.com/ttadC1</a>

If I use the typedef M3f (by uncommenting the line marked as "Works" and
commenting out the line marked as "Does not work"), then it compiles with no
warnings or issues.

My exact version of clang:

$ clang++ --version
Apple LLVM version 5.0 (clang-500.2.78) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>