<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><div>On Mar 8, 2013, at 3:41 , Nicola Gigante <<a href="mailto:nicola.gigante@gmail.com">nicola.gigante@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello.<br><br>I'm not sure why this piece of code doesn't compile, but I suspect a bug.<br>This happens with the clang trunk (r176686) (C++11 mode)<br><br>The compilation succeeds if value is made const static OR if I put parenthesis around test<1, N>::value.<br><br>template<int I, int N><br>struct test<br>{<br> bool value = test<1, N>::value;<br>};<br><br>template<int N><br>struct test<1, N><br>{<br> static const bool value = true;<br>};<br><br>$ ./llvm/build/bin/clang++ -std=c++11 -fsyntax-only test.cpp<br>test.cpp:4:26: error: declaration of 'N' shadows template parameter<br> bool value = test<1, N>::value;<br> ^<br>test.cpp:1:21: note: template parameter is declared here<br>template<int I, int N><br> ^<br>test.cpp:4:27: error: expected ';' at end of declaration list<br> bool value = test<1, N>::value;<br> ^<br> ;<br>test.cpp:4:24: error: expected '>'<br> bool value = test<1, N>::value;<br> ^<br>3 errors generated.<br><br>Am I missing something (or is it already known)?<br></blockquote></div><br><div>Clang is parsing this as:</div><div><br></div><div>bool value = (test < 1), N > ::value;</div><div><br></div><div>The first error is because it thinks you're declaring "bool N", the second because "> ::value" isn't a valid initializer for "bool N", and the third because "test < 1" isn't a complete template reference.</div><div><br></div><div>I can't be sure whether this is correct, and clearly we could have better recovery, but it explains what's going on here. I think it's due to the fact that we don't know if "test" is a template until <i>after</i> it's been parsed—it could be an integer that we're trying to compare against 1.</div><div><br></div><div>At the very least, though, please file a bug for better error recovery.</div><div><br></div><div>Jordan</div></body></html>