[cfe-dev] Bug in template parsing?

Nicola Gigante nicola.gigante at gmail.com
Fri Mar 8 03:41:12 PST 2013


Hello.

I'm not sure why this piece of code doesn't compile, but I suspect a bug.
This happens with the clang trunk (r176686) (C++11 mode)

The compilation succeeds if value is made const static OR if I put parenthesis around test<1, N>::value.

template<int I, int N>
struct test
{
    bool value = test<1, N>::value;
};

template<int N>
struct test<1, N>
{
    static const bool value = true;
};

$ ./llvm/build/bin/clang++ -std=c++11 -fsyntax-only test.cpp
test.cpp:4:26: error: declaration of 'N' shadows template parameter
    bool value = test<1, N>::value;
                         ^
test.cpp:1:21: note: template parameter is declared here
template<int I, int N>
                    ^
test.cpp:4:27: error: expected ';' at end of declaration list
    bool value = test<1, N>::value;
                          ^
                          ;
test.cpp:4:24: error: expected '>'
    bool value = test<1, N>::value;
                       ^
3 errors generated.

Am I missing something (or is it already known)?

Bye,
Nicola



More information about the cfe-dev mailing list