http://llvm.org/bugs/show_bug.cgi?id=17610

            Bug ID: 17610
           Summary: Clang requires a typedef when declaring and
                    initializing a templated member variable
           Product: clang
           Version: 3.3
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

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: http://ideone.com/ttadC1

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to